Where is my sdcard location on 4.4.2?

On Android 4.4.2 Environment.getExternalStorageDirectory().getPath() returns /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?

  • Animate change width of android RelativeLayout
  • How much is too much memory allocation in NDK?
  • main cannot be resolved or is not a field
  • SVN and syntax highlighting on Android
  • How to put Google Maps V2 on a Fragment Using ViewPager
  • OCSP certificate stapling in Android
  • Why is library module android.support.test not visible in add dependency
  • transformClassesAndResourcesWithProguardForRelease FAILED
  • Implementing a TabListener using the Support Library
  • Android Drawable Images from URL
  • Couldn't expand RemoteViews: MediaSessionCompat and NotificationCompat.MediaStyle on HUAWEI devices
  • How to set the custom size of the stars in RatingBar
  • 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 /mnt/shell/emulated/0/Download directory.

    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

    More joy… http://forums.bignerdranch.com/viewtopic.php?f=414&t=7407

    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.

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.