Am I correct in understanding that, on Android, if you want to save/persist images that you take with the camera, you can only create the image on external storage first? And if no external storage exists, then you're out of luck? But assuming the storage does exist, I can always move it to wherever I want (including the private internal storage) after the photo has been taken?
It depends on what you mean by "images that you take with the camera".
If you are using the camera APIs directly (e.g., android.hardware.Camera
), or are using libraries in your app that use the camera APIs directly, you should be able to store the images on internal storage without issue.
If you are trying to use ACTION_IMAGE_CAPTURE
, you are at the mercy of whatever third-party camera app handles the request. One approach is to just ask for a thumbnail, with a plain ACTION_IMAGE_CAPTURE
Intent
, but the image will be thumbnail-sized. However, you get the Bitmap
via an extra on the result Intent
, and you can write that to internal storage.
You are welcome to use EXTRA_OUTPUT
and a content:
Uri
, pointing at a ContentProvider
from your app. Ideally, this works, and your ContentProvider
will get the image and can save it to internal storage. And I would assume that some camera apps can handle this correctly. However, I would also expect:
Some camera apps to not recognize the content:
scheme, try to use the path as a file, and crash
Some camera apps to not recognize the content:
scheme, try to use the path as a file, fail, catch the exception, and ignore your EXTRA_OUTPUT
Some camera apps to ignore EXTRA_OUTPUT
in general
Some camera apps to have other bugs in their ACTION_IMAGE_CAPTURE
handling that interfere with your app
ACTION_IMAGE_CAPTURE
is intrinsically unreliable. It is easy to try, but it will not work 100% of the time, due to camera app bugs. Use it only if you are in position to tell the user ¯\_(ツ)_/¯
when it does not work.
And if no external storage exists, then you're out of luck?
If the user has no external storage, they have much bigger problems than your app not working.
But assuming the storage does exist, I can always move it to wherever I want (including the private internal storage) after the photo has been taken?
"Always" is a strong statement with respect to ACTION_IMAGE_CAPTURE
. Let's say that if you get a picture that is saved on external storage, and if you have permission to work with external storage, then you can move it to internal storage.