I've got an Android app, and in it I'm using the camera to take photos. I want these photos to stay 100% internal to my own app for privacy reasons. On certain devices (not all of them) the photos taken within my app are being copied into the camera roll on the phone. I want to know if there is anything more I can do to keep them out of the camera roll. Below is what I've attempted.
Before getting to what I've tried, I've seen this post on SO that suggests going into the camera roll and deleting pictures. This is NOT an ideal situation for multiple reasons:
I am saving my photos directly to the INTERNAL storage for my app.
File folder = new File(activity.getFilesDir(), "pictures");
folder.mkdirs();
File file = new File(folder.getAbsolutePath() + File.separator + filename + ".jpeg");
URI uri = FileProvider.getUriForFile(activity, myAppsFileProviderAuthority(), file);
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
activity.startActivityForResult(intent, INTENT_RESULT_VALUE);
From what I can tell, this alone should keep anything else from being able to touch my photos, but they're still showing up in the gallery on certain devices.
I've also tried saving to the external storage directory instead of internal storage by using getExternalFilesDir()
instead of activity.getFilesDir()
above, since according to the Android docs:
if you'd like the photos to remain private to your app only, you can instead use the directory provided by
getExternalFilesDir()
.
Same result, and I don't want to save the images here anyway.
I also tried creating a tempFile instead of a regular file for interim storage of my image, but I get the same result:
File file = File.createTempFile(filename, ".jpeg", folder);
I also happened on an article that said you could create a file named .nomedia
in the directory where the photos exist, which could prevent some file scanners from accessing photos from within it, but that didn't stop anything.
Are there any other options to keep my photos 100% internal to my app without having to go into the camera roll and delete files?
I want these photos to stay 100% internal to my own app for privacy reasons
Then you should not be using ACTION_IMAGE_CAPTURE
. By definition, that delegates the photo-taking to an arbitrary app, one of hundreds of possible apps based on device and user.
Instead, take the picture yourself, in your own app, either using the camera APIs directly or by using a library that wraps them.
On certain devices (not all of them) the photos taken within my app are being copied into the camera roll on the phone
Some camera apps will save the photos where they want, possibly in addition to copying the photo to your EXTRA_OUTPUT
location. That is up to the developers of those camera apps, not you. Arguably, that behavior is a bug, but you have no practical means of getting any camera app developer to fix that bug, let alone developers of all buggy camera apps.