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 8235069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:40:49+00:00 2026-06-07T18:40:49+00:00

I have created a program to capture the image and that is getting stored

  • 0

I have created a program to capture the image and that is getting stored into sdcard/dcim/camera folder. Now I am trying to save the captured image in my own directory created in sdCard, say “/somedir”.

I am able to make the directory programmatically but the image file is not getting stored in it.

Can anybody tell me where I am doing wrong here??

Here is the code....


File folder = new File(Environment.getExternalStorageDirectory() + "/abc");

Bitmap mybitmap1;     //mybitmap1 contain image. So plz dont consider that I don't have image in mybitmap1;
if(!folder.exists())
        {
            success = folder.mkdir();
            Log.i("Log", "folder created");
        }
        else
        {
            Log.i("Log", "Folder already present here!!");
        }
        String fname = date +".jpg";
        file = new File( folder,fname);
        if (file.exists ()) 
            file.delete (); 
        capturedImageUri = Uri.fromFile(file);

        FileOutputStream out;
            byte[] byteArray = stream.toByteArray();
            try {

                   out = new FileOutputStream(file);
                   mybitmap1.compress(Bitmap.CompressFormat.JPEG, 100, out);
                   out.flush();
                   out.close();
                   MediaStore.Images.Media.insertImage(getContentResolver(), mybitmap1, file.getName(), file.getName());
                   //MediaStore.Images.Media.insertImage(getContentResolver(),file.getAbsolutePath(),file.getName(),file.getName());


            } catch (Exception e) {
                   e.printStackTrace();
            }
  • 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-07T18:40:51+00:00Added an answer on June 7, 2026 at 6:40 pm

    Refer the below code

        public void onActivityResult(int requestCode, int resultCode, Intent data) {
    
        super.onActivityResult(requestCode, resultCode, data);
        if(resultCode == RESULT_OK && requestCode == 1 ) {
    
        final Uri selectedImage = data.getData(); 
    
        try {
                bitmap = Media.getBitmap(getContentResolver(),selectedImage);
                ByteArrayOutputStream bytes = new ByteArrayOutputStream();
                bitmap.compress(Bitmap.CompressFormat.JPEG, 90, bytes);
    
                File f = new File(Environment.getExternalStorageDirectory()
                        + File.separator
                        + filename);
                f.createNewFile();
                FileOutputStream fo = new FileOutputStream(f);
                fo.write(bytes.toByteArray());
    
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
           }
          }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a non-form c# program that uses the NotifyIcon class. The text
Ok I have created a program which saves text into settings file. So at
I have created a little program that reads in a Java file and feeds
I have created a program in C++ but I want that the program download
I have created a program in c++ that doesn't have any GUI. When this
I have created a program that takes a users input of a bunch of
I have created a program, i need to save the content into mysql database.
I have a program that logs into a server and issues commands. The results
I have created this program: from PIL import Image, ImageDraw a = Image.open(r'C:\Users\damian\Desktop\a.png') draw
I have created this program that takes two inputs and prints them out (simple,

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.