Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8003993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:47:59+00:00 2026-06-04T16:47:59+00:00

I am trying to save image to SD card and I added some code

  • 0

I am trying to save image to SD card and I added some code for it.But after clicking the “OK”/Checkmark in the camera, my app exits.Would I have to check if the directory that I am trying to store it in exists?How would i do that?.. !file.exists(){file.mkdirs}? ..In my code I have tried to store it in /Android folder which exists in every SD card.

           file = new File(Environment.getExternalStorageDirectory().getPath()
                 + "/Android/" + "bhe_app" + ".jpg");

    imageUri = Uri.fromFile(file);

i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
        i.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);

        startActivityForResult(i, cameraData);

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // TODO Auto-generated method stub
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == RESULT_OK) {
        Bundle extras = data.getExtras();
        bmp = (Bitmap) extras.get("data");
        iv.setImageBitmap(bmp);


    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T16:48:00+00:00Added an answer on June 4, 2026 at 4:48 pm

    Create the directory before creating the File.

    boolean createdDirectory = new File(Environment.getExternalStorageDirectory().getPath() + "/directory1/directory2/directory3/").mkdirs();
    

    the variable createdDirectory will be

    true if and only if the directory was created, along with all
    necessary parent directories; false otherwise

    You will have to make sure that your app has the permission to write to the SD Card(Check your AndroidManifest.xml)

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some help here.. Im trying to save a canvas image after drawing..
I am trying to save an image into a MemoryStream but it is failing
In my app, I am trying to save and retrieval of an image in
I'm trying to take an image file, do some stuff to it and save
I am currently trying to save a bitmap image, but the background is changing
I'm trying to save contents of an NSView as an image, but, only the
I'm trying to save an image to my sdcard but running into the following
I am trying to save an Image to Derby Db(JDBC),but it gives exception void
I'm trying to save an image to a folder in .NET C# but I
I am trying to save image to database with Create method. but when try

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.