1

I have a AVD with Android 4.0.3. I need work with the media store. I worked with folder camera in SDCARD and I put it my images, but I need upload images to folder Camera in the internal memory with the DDMS. However, I don't found any folder to upload my images. I try to take a picture but these are stored in sdcard and I have not found any way to change the settings to save the photos in the internal memory.

How I can save an image from the camera in the internal memory? Is possible make a folder to store images and that images are displayed in the gallery?

Thank you very much.

user1242132
  • 9
  • 1
  • 1
  • 6
  • see http://stackoverflow.com/a/5252540/416412 – james Sep 10 '12 at 13:54
  • Thank you binny for your answer. I would like simply to create a folder with DDMS and upload the images. I just need to access the images. If this is not possible I make a program with your answer. – user1242132 Sep 10 '12 at 14:34

3 Answers3

1

Take an image from camera and capture it on ImageView. Here, I am writing the code to save image of ImageView in internal memory.

     Bitmap bm;

     View v=imageView;
     v.setDrawingCacheEnabled(true);
     bm=Bitmap.createBitmap(v.getDrawingCache());
     v.setDrawingCacheEnabled(false);

     String fileName="image.png";
     File file=new File(fileName);

     try 
     {

        FileOutputStream fOut=openFileOutput(fileName, MODE_PRIVATE);
        bm.compress(Bitmap.CompressFormat.PNG, 100, fOut);

     }
     catch (Exception e) 
     {
        e.printStackTrace();
     }
Himanshu Mahajan
  • 4,779
  • 2
  • 36
  • 29
0

The official android documentation for Camera shows how you can capture an image and save it in a location in such a way that it is also visible in the gallery.

This part especially shows how to save your captured image in the most efficient manner (on the SD card).

Here you can find information about how to store your picture on internal memory (not the SD card).

zeiger
  • 700
  • 5
  • 16
  • Hello zeiger and thank you for your answer. I read the documentation and in the part of the camara say: Media files created by users such as pictures and videos should be saved to a device's external storage directory (SD Card) to conserve system space and to allow users to access these files without their device. But, don't say anything about internal storage. I need access to gallery of internal memory, not to an application's private storage. – user1242132 Sep 11 '12 at 05:58
  • Refer to [link](http://developer.android.com/guide/topics/data/data-storage.html#filesInternal) to find out about storing your images in internal storage – zeiger Sep 11 '12 at 11:22
  • Forgive me, but after reading the link I can't find any reference to the internal memory storage allow me to write data outside the application directory itself. Thank you very much. – user1242132 Sep 12 '12 at 13:51
0

Go to Device Settings>Device>Applications>Application Manager>"your app">Permissions>Enable Storage permission!

Manifest:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

To save:

FileOutputStream outStream = null;
File sdCard = Environment.getExternalStorageDirectory();
File dir = new File(sdCard.getAbsolutePath() + "/YourFolderName");
dir.mkdirs();
String fileName = String.format("%d.jpg", System.currentTimeMillis());
File outFile = new File(dir, fileName);
outStream = new FileOutputStream(outFile);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outStream);
outStream.flush();
outStream.close();
Shravan DG
  • 527
  • 1
  • 5
  • 16