Moon Light Box

Time is Money

Posts match “ sdcard ” tag:

Android - /storage/emulated/legacy vs /storage/emulated/0

| Comments

Usually, we get the external storage via this

Environment.getExternalStorageDirectory().getAbsolutePath();

And get the result.

/storage/emulated/0

Then we use adb to see the path.

adb shell ls -la /storage/emulated/0
/storage/emulated/0: No such file or directory

Again, we can see the correct path.

adb shell ls -la /storage/emulated/
lrwxrwxrwx root     root              2015-04-22 14:05 legacy -> /mnt/shell/emulated/0

But how do we get /storage/emulated/legacy?
According to AOSP, we can echo $EXTERNAL_STORAGE.

adb shell echo $EXTERNAL_STORAGE
/storage/emulated/legacy

Use code method.

System.getenv("EXTERNAL_STORAGE");

Reference:http://developer.android.com/guide/topics/data/data-storage.html#filesExternal