Home » Android » android – Path of getExternalStoragePublicDirectory on Samsung Galaxy Note

android – Path of getExternalStoragePublicDirectory on Samsung Galaxy Note

Posted by: admin June 16, 2020 Leave a comment


In my app, I am creating files which are stored in the devices Downloads directory. All of my users are happy with this mechanism… except the ones using a Samsung Galaxy Note.

It’s kind of hard to debug without owning such a device. Within my code, I am using

File newFile = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS),
    if (newFile.exists()) {
        // show error
    } else {
        if (!newFile.mkdirs()) {
            // show error

to find the path for the target directory. On the Galaxy Note, the path returned is “/storage/sdcard0/Download”. However, on the local file system directory is written in lowercase (“download”) and the files created by my app do not obviously not exist on the local file directory. At least my users complain about this. I assume the problem to be related with the lowercase/uppercase difference in the path.

Does anybody have an idea why this works on all devices except the Galaxy Note?


How to&Answers:

There is no guarantee that the location returned by getExternalStoragePublicDirectory() actually exists. Yours may be the first app that needs a particular one of those directories. Hence, it is your job to call mkdirs() on that location, on all devices, not just this one.

Beyond that, as to why somebody else (Samsung or another third-party app) is creating a lowercase download directory, the only way to determine “why” is to figure out who created that directory and then contact that developer. This is unlikely to be a worthwhile investment in time.

So long as you are calling mkdirs() to create Download, whatever other directories that may exist are not really your concern. If you wanted to detect possible collisions like this, and warn the user, you could do that, though I have no idea if that would be worthwhile.