Reputation: 415
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?
Upvotes: 3
Views: 1290
Reputation: 34833
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.
Upvotes: 1