Saving files to external storage, custom directory.


Senior Member
May 6, 2011
Hey all -
Have a question.
I want to call the Camera intent, but have the camera save to a custom file.
I've read this:
And the only two options it gives is 'Save to a public directory" (like \Pictures, \Ringtones, etc), or "Save to a Provate Directory".

The latter sounds like it's what I want to do - but mentioned 'getExternalFilesDir()' function retrieves my application's custom data directory (which is (1)removed when the app is uninstalled, and (2)difficult to find when the phone is plugged into a computer - to copy the saved files from.)

What I'd REALLY wanna do is save my files to a root directory in the external storage. (Like, "/<sdcard mount path>/PicLogger/<file>").

Anyone know of a guide, or examples that show how to save images through the camera into a custom directory like this?
Dec 2, 2019
You can save the file wherever you want, given that you have permission to write to SD card, by passing the file URI as MediaStore.EXTRA_OUTPUT in the MediaStore.ACTION_IMAGE_CAPTURE intent. See Save the full-size photo.

That being said, you should prefer something like "DCIM/YourAppName" or "Pictures/YourAppName", which apps like Google PhotoScan etc have been doing.
new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM), "YourAppName")
Apps should not create their own directories directly under the SD card root directory, and if they want to make something visible to user, it should be under one of the standard directories, preferrably under a subdirectory named after your app.

Or if you want to support scoped storage since Q, you can check out this SO answer.