Aritra Roy Aritra Roy - 4 months ago 37
Android Question

Android Storage Locations

Can someone explain in detail about the various storage locations in Android,


  1. /sdcard/ (along with /root/ directory and other system-level directory)

  2. /storage/emulated/0/

  3. /storage/emulated/legacy/

  4. /storage/sdcard0/



Really confused with these? And are there any methods to access them programatically whenever needed?

Answer

I can't speak for storage paths on all phones. But I can explain you clearly with respect to my phone; Coolpad Note 3 - running on Android 5.1. Because, the storage locations or paths may vary on other mobile phones depending on your vendor/manufacturer and different versions of Android OS.

Generally, /someDirectory or /root/someDirectory or >root>someDirectory are same. Which among them is picked to display; depends on your file manager.

On my phone:

/root/sdcard is storage path to phone's internal memory(16 GB in my case).

Both /storage/emulated/0/ and /storage/sdcard0/ are symlinks to /root/sdcard. It means, these two paths are also storage paths of my phone's internal memory.

/storage/sdcard1/ is storage path of my micro SD card.

On ANY phone:

Before Android 4.2, only one user could user your phone. There was no concept of two or more users creating separate profiles and logging into the same phone.

As a result, there were no such paths like /storage/emulated/someDirectory

The emulated directories came up after the introduction of multiuser API in Android 4.2.

Source: source 1 and source 2

So from then,

/storage/emulated/legacy/ points to External Storage(Android terminology) of the currently working user. It would be a symlink.

/storage/emulated/anyNumber/ points to External Storage(Android terminology) of a specific user.

On my phone: I have two users.

internal memory location for user1 (Ramesh) is: /storage/emulated/0/

internal memory location for user2 (Kishore) is: /storage/emulated/10/

So /storage/emulated/legacy/ would point to /storage/emulated/0/ if user1(Ramesh) logs in & uses the phone. In this case, /storage/emulated/legacy/ would be a symlink to /storage/emulated/0/

And /storage/emulated/legacy/ would point to /storage/emulated/10/ if user2(Kishore) logs in & uses the phone. In this case, /storage/emulated/legacy/ would be a symlink to /storage/emulated/10/

If you want to know more about storage paths, please go through this answer on android.stackexchange.com

I specifically mentioned External Storage(Android terminology) above. Because, the Internal and External Storage terminology according to Google/official Android documentation is quite different to that of normal Android OS user.

If you want to know more about storage terminology, class and methods to store in The Internal and External Storage; please go through my post on stackoverflow documentation Android: Internal and External Storage - Detailed Explanation