3

I'm trying to save the image captured via android camera in a custom location. My code looks like this:

Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
File f = File(android.os.Environment.getExternalStorageDirectory(), "test.jpg");
intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(f));
startActivityForResult(intent, SUB_ACTIVITY_CAMERA_PREVIEW);

The image is being saved to the desired location but it is also being saved to the default camera folder which is causing it to be displayed in the gallery. Any suggestions?

bala
  • 415
  • 3
  • 13
  • Possible duplicate of [Deleting a gallery image after camera intent photo taken](http://stackoverflow.com/questions/6390163/deleting-a-gallery-image-after-camera-intent-photo-taken) – Moritz Both Jan 12 '17 at 20:16

1 Answers1

1

Include an empty file named .nomedia in your external files directory (note the dot prefix in the filename). This will prevent Android's media scanner from reading your media files and including them in apps like Gallery or Music.

Labeeb Panampullan
  • 34,521
  • 28
  • 94
  • 112
  • The gallery isn't actually pulling the image from the custom location. The same image is being saved to my custom location and the camera directory (dcim/Camera). So if I delete the file from this location, the image is not displayed in the gallery. – bala Jun 13 '11 at 05:55
  • @bala, did you found a answer for this issue. Because I got the same issue. Thanks – Chinthaka Nov 10 '11 at 12:29