A Brief Analysis of the Common Storage Paths of Android Mobile Phones

Keywords: Android Mobile shell MIUI

Memory and External Memory:

  • Early Android phones were divided into memory and external memory. Memory was provided by mobile phones, and external memory could be added.
  • Nowadays, Android phones generally have only memory, no external memory.

Running memory other memory:

Memory can be divided into running memory and other memory, such as 6G/64G mobile phone refers to 6G running memory and 64G other memory.

  • Running memory uses RAM (Random Access Memory) and reads and writes faster.
  • Other memory uses ROM (Read Only Memory), which is cheaper.
    (The original ROM was read-only, and then there was a readable and writable Flash Memory, which is still customarily called ROM)

Private and shared memory:

Other memory can be divided into private memory and shared memory.

  • Private memory includes directories such as data, cache, system, etc.
  • Common memory refers to the storage directory.

/sdcard,/storage/sdcard,/mnt/sdcard,/storage/sdcard0:

  • / sdcard, / mnt/sdcard, / storage / sdcard 0, are all soft links to: / storage/emulated/0
  • / storage/sdcard does not exist

/ data/data and/data/user/0:

  • For single users, / data/data refers to the user data folder
  • In multi-user scenarios, / data/user/0 refers to the data folder of user 0.

/data/data,/sdcard/Android/data,/sdcard:

  • / The data/data/package name directory will be deleted automatically after the application is uninstalled. Only the application can be read and written without permission.
  • / The sdcard/Android/data/package name directory will be deleted automatically after the application is uninstalled. All applications can be read and written. This application does not need permission to read and write, and other applications need permission to read and write.
  • / The other directories in sdcard will not be deleted automatically after the application is uninstalled. All applications can be read and written. Read and write permissions are required.

/ The size of the data/data/packagename directory:

  • / The size of data / data / package name is the size of / data. Looking through adb shell df, we find that the total space and available space of data and sdcard are identical, that is, they are located in a partition and share the same space.
    (See http://www.miui.com/thread-1355995-1-1.html.)

  • / The Android/data directory is also located in the sdcard partition.

    // Millet mix 2, android 9.0
    // Asus, android 5.0
    chiron:/ $ df -h
    Filesystem       Size  Used Avail Use% Mounted on
    rootfs           2.6G  6.1M  2.6G   1% /
    tmpfs            2.7G  804K  2.7G   1% /dev
    tmpfs            2.7G     0  2.7G   0% /mnt
    /dev/block/dm-0  4.8G  3.1G  1.6G  65% /system
    none             2.7G     0  2.7G   0% /sys/fs/cgroup
    /dev/block/sda17  51G   17G   34G  34% /data
    /dev/block/sde37  12M   10M  1.4M  88% /system/vendor/dsp
    /dev/block/sde42 806M  429M  361M  55% /cust
    /dev/block/sda16 232M  4.2M  220M   2% /cache
    /dev/block/sda10 4.9M  160K  4.8M   4% /dev/logfs
    /data/media       51G   17G   34G  34% /storage/emulated
    

Commonly used storage path acquisition methods:

Environment.getDataDirectory().absolutePath = /data
Environment.getRootDirectory().absolutePath = /system
Environment.getDownloadCacheDirectory().absolutePath = /cache
Environment.getExternalStorageDirectory().absolutePath = /storage/emulated/0
context.getCacheDir() = /data/user/0/packagename/cache
context.getFilesDir() = /data/user/0/packagename/files
context.getExternalCacheDir() =  /storage/emulated/0/Android/data/packagename/cache
context.getExternalFilesDir(null) = /storage/emulated/0/Android/data/packagename/files

Directory testing:

Millet mix 2, android 9.0 (as shown below)
Millet 4, android 6.0 (as shown below)
Glory 5A, android 6.0 (one more exists than the figure below, / storage / sdcard 0 is also a soft link to / storage/emulated/0)

Posted by mgelinas on Sun, 11 Aug 2019 23:55:19 -0700