Where is my sdcard location on 4.4.2?
On Android 4.4.2
/storage/emulated/0 but this path does not exist on my Nexus5 Android 4.4.2.
Environment.getExternalStorageDirectory().getPath() worked up until Android 4.4.2.
How can I get the
/sdcard path on Android 4.4.2?
3 Solutions collect form web for “Where is my sdcard location on 4.4.2?”
This path does not exist on my Nexus5 Android 4.4.2.
Yes, it does, for your process at runtime.
For example, this sample project downloads a file to
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS). If you log the location at runtime, when running it on a Nexus 5, it is reported as
/storage/emulated/0/Download. And the download succeeds.
If you are looking for
/storage/emulated/0 via DDMS or
adb shell, you will not find it. For those tools, default external storage is
/mnt/shell/emulated/0. Hence, the downloaded file from the above sample appears in the
AFAIK, the difference is tied to providing separate external storage to secondary accounts.
Sometimes /storage/emulated/0 can be written to, but reads fail… so tests for “writability” are not sufficient. This is such an annoying problem, I have come up with an equally annoying but effective solution.
Hardcode “/mnt/sdcard” Yea, I said it.
Looks like someone else said it first … storing android application data on SD Card
The Storage Options documentation says to use Environment.getExternalStorageDirectory() (as you are already correctly using). This function is available on all versions of Android.
Are you seeing it return a path that isn’t actually available on a 4.2 device?
Please note (from Environment.getExternalStorageDirectory()):
Applications should not directly use this top-level directory, in order to avoid polluting the user’s root namespace. Any files that are private to the application should be placed in a directory returned by Context.getExternalFilesDir, which the system will take care of deleting if the application is uninstalled. Other shared files should be placed in one of the directories returned by getExternalStoragePublicDirectory(String).
Writing to this path requires the WRITE_EXTERNAL_STORAGE permission, and starting in read access requires the READ_EXTERNAL_STORAGE permission, which is automatically granted if you hold the write permission.
Starting in KITKAT, if your application only needs to store internal data, consider using getExternalFilesDir(String) or getExternalCacheDir(), which require no permissions to read or write.