The example in the Javadoc for Environment.getExternalStoragePublicDirectory() mentions Context.getExternalMediaDir() but this method isn’t available in my Android API version and I can’t find it documented anywhere in any version. Is this a typo or something that never made it to release?
void createExternalStoragePublicPicture() {
// Create a path where we will place our picture in the user's
// public pictures directory. Note that you should be careful about
// what you place here, since the user often manages these files. For
// pictures and other media owned by the application, consider
// Context.getExternalMediaDir().
File path = Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES);
I believe it is just incorrectly named; I think they meant to say “
Context.getExternalFilesDir()“. This may have been a typo, or the method may have been renamed later on.Based on the explanation in the comments (“pictures and other media owned by the application“), it closely matches that of
getExternalFilesDir(String type), which is “where the application can place persistent files it owns“. Note that you can passnulltogetExternalFilesDir, which returns the root directory, or specified to return a type of folder you’re looking for.I will say, I am speculating somewhat here. However, this seems to be the most likely explanation for this seemingly nonexistent method.