Android's filesystem hierarchy is a bit complex and people often find it difficult to grasp. A major reason for confusion is that Android isn't very expressive in explaining these things and it's not very clear which files Android put in which category. Another reason is that mostly devices are not rooted and users don't have access to filesystems to verify the things themselves. We can try to understand it from root.

VIDEOS, PICTURES, AUDIO AND "OTHER":
---

Android uses file extensions to decide if a file in Public [Shared / External Storage][1] (i.e. `/sdcard` [excluding][2] the private directories of apps) is video, picture or audio. This [header file][3] defines a mapping between file extensions and categories. Further details can be found in [this answer][4].

Simply put, we can use file extensions to categorize files and calculate their size:
```
~$ find -H /sdcard/ -type f ! -path '/sdcard/Android*' | grep -iE '\.3g2$|\.3gp$|\.3gpp$|\.3gpp2$|\.asf$|\.asx$|\.avi$|\.dif$|\.dl$|\.dv$|\.fli$|\.lsf$|\.lsx$|\.m4v$|\.mkv$|\.mng$|\.mov$|\.movie$|\.mp4$|\.mpe$|\.mpeg$|\.mpg$|\.mxu$|\.qt$|\.ts$|\.vob$|\.webm$|\.wm$|\.wmv$|\.wmx$|\.wrf$|\.wvx$' | xargs -I {} du -b '{}' | sort -n | awk '{sum += $1} {print} END {print sum}'
...
75696063        /sdcard/DCIM/Camera/VID_20190726_190531.mp4
97849262        /sdcard/DCIM/Camera/VID_20190721_142818.mp4
331238039       /sdcard/TIMELAPSE OF THE FUTURE_ A Journey to the End of Time (4K).mp4
1554180683
```
So I have 1.55 GB of videos on my `/sdcard`.
```
~$ find -H /sdcard/ -type f ! -path '/sdcard/Android*' | grep -iE '\.art$|\.arw$|\.bmp$|\.cr2$|\.dng$|\.gif$|\.jng$|\.jpe$|\.jpeg$|\.jpg$|\.nef$|\.nrw$|\.orf$|\.pbm$|\.pcx$|\.pef$|\.pgm$|\.png$|\.pnm$|\.ppm$|\.psd$|\.ras$|\.rgb$|\.rw2$|\.srw$|\.svg$|\.svgz$|\.tif$|\.tiff$|\.wbmp$|\.webp$|\.xbm$|\.xpm$|\.xwd$' | xargs -I {} du -b '{}' | sort -n | awk '{sum += $1} {print} END {print sum}'
...
31944   /sdcard/.recycle/1565980569828.3/2080952923/Screenshot_20190816-155104_Firefox.png
34099   /sdcard/OLD_sdcard/Download/iptables_overview.jpg
6839118 /sdcard/DCIM/Camera/PANO_20190421_132245.jpg
7726000 /sdcard/DCIM/Camera/IMG_20181123_144811.jpg
669063808
```
And 669 MB of pictures. Combined with videos it becomes 2.22 GB.
```
~$ find -H /sdcard/ -type f ! -path '/sdcard/Android*' | grep -iE '\.aac$|\.aif$|\.aifc$|\.aiff$|\.amr$|\.awb$|\.flac$|\.gsm$|\.m3u$|\.m4a$|\.mka$|\.mp2$|\.mp3$|\.mpega$|\.mpga$|\.oga$|\.ogg$|\.pls$|\.ra$|\.ram$|\.rm$|\.sd2$|\.snd$|\.wav$|\.wax$|\.wma$' | xargs -I {} du -b '{}' | sort -n | awk '{sum += $1} {print} END {print sum}'
...
196556  /sdcard/OLD_sdcard/Alarms/Freedom.ogg
451614  /sdcard/OLD_sdcard/CallRecordings/0507189091_190225_191938461.amr
5652322 /sdcard/.recycle/1564398739475.3/710629278/L'Orfeo(preview).mp3
186868393
```
And 187 MB of audios. Now total space taken by files:
```
~$ du -bs --exclude=/sdcard/Android /sdcard/
5330784600      /sdcard/
```
It's 5.3 GB. Subtracting video, pictures and audio, it's 2.89 GB which is the size of "Other"; shown as "Files" on my device:

<img src="https://i.sstatic.net/Ay9j2.png" width="300" height="360">

-----
Non-root part is over here. Next to explore the `/data` partition **you need root access**. First to make it clear, throughout the whole life of a device, a common user interacts only with one partition labeled `userdata`. But it's not very uncommon to have 50+ partitions on Android devices (details can be seen in [this thread][5]). So here we are talking about the space usage on `userdata` partition which is mounted at `/data`. One of its sub-directory `/data/media/0` is the one we see in file explorers or at `/sdcard` or at `/storage/emulated/0`. See [What is /storage/emulated/0?][6] for details.

TOTAL SPACE USAGE:
----

Now have a look at space usage reported by Android. It says 16.73 GB out of 32 GB are used. Let's analyze.
```
~# cat /sys/block/mmcblk0/size 
61071360
~# df -B1 --output=size /data
  1B-blocks
25762942976
```
***Note:*** Don't confuse the units. 61071360 sectors equal 31268536320 bytes, which equal 31.27 Gigabytes (GB) or 29.12 Gibibyte (GiB).

Total available size of eMMC is 31.27 GB (ignoring e.g. RPMB and provisioned space etc.) and size of `/data` filesystem is 25.76 GB (See! I thought it would be 32.00 GiB). It means that 5.5 GB space was occupied when the device was shipped from the factory. It's mainly taken by the `system`, `vendor` and `cache` partitions, and a small part by other partitions. Partition table takes a few KBs but there are possibly a few MBs left free in between partitions, some space is wasted due to encryption, and so on. Following screenshot shows the complete partition table:

<a href="https://i.sstatic.net/3sezU.png"><img src="https://i.sstatic.net/3sezU.png" width="100"></a>  
<sup>(Click image for enlarged view)</sup>

Now coming to the used space:
```
~# df -B1 --output=used /data
       Used
10407436288
~# du -b -d1 /data | sort -n
...
30932548        /data/system
89343105        /data/user_de
252376438       /data/dalvik-cache
1537995332      /data/app
1817762284      /data/data
5460784600      /data/media
9250761612      /data
```
Space usage reported by filesystem is 10.4 GB, while the apparent size of files is 9.25 GB. This difference of 1.15 GB could be variable and is used by the filesystem. Details can be found in [this answer][7]. May be a part of it is being used by `f2fs` log structure on my device.

So total used space on device is 15.9 GB (5.5 and 10.4) out of 31.27 GB. Note the difference with the values in screenshot. The difference in total size could be because of [rounding-off][8] the [sum][9] of `/data` and `/system` to the nearest power of 2.

APPS SPACE USAGE:
----
5.3 GB out of 9.25 GB is used by the public files in `/sdcard` as explained in the start. Rest of the 3.95 GB space is mainly taken by three categories of files. Keeping things simple, following are the major directories which sum up to total app size <sup>([1][10], [2][11], [3][12], [4][13])</sup>:
```
App size    /data/app/<pkg>*
            /data/dalvik-cache/<arch>/<pkg's_dex_odex_vdex_art_oat>
            /storage/emulated/<user_id>/Android/obb/<pkg>
            /data/misc/profiles/ref/<pkg>
Cache       /data/user/<user_id>/<pkg>/*cache
            /data/user_de/<user_id>/<pkg>/*cache
            /storage/emulated/<user_id>/Android/data/<pkg>/*cache
User data   /data/user/<user_id>/<pkg>
            /data/user_de/<user_id>/<pkg>
            /storage/emulated/<user_id>/Android/data/<pkg>
            /storage/emulated/<user_id>/Android/media/<pkg>
            /data/misc/profiles/cur/<user_id>/<pkg>
```
- User data size should exclude Cache size.
- For user apps compiled binary files are stored in installation directory (`/data/app/<pkg>/oat/<arch>`) since Lollipop. But for system apps those are saved to `/data/dalvik-cache` which is counted for apps size. Actual `.apk` files of system apps are [not counted][14], except if an app is updated. `.odex` files for Android's framework apps (`.apk`/`.jar`) however might be already stored in `/system/framework/` having only symlinks in `/data/dalvik-cache/`. Things have [changed][15] with A/B implementation.
- For more details see [Where Android apps store data?][16]

Taking sum of all these directories:
```
~# du -sb /data/app /data/misc/profiles/ /data/dalvik-cache/ /storage/emulated/*/Android/ /data/user/*/ /data/user_de/ |  sort -n | awk '{sum += $1} {printf "%-15s%s\n",$1,$2} END {print sum}'
94152          /storage/emulated/11/Android/
611998         /data/misc/profiles/cur/10/
837897         /storage/emulated/10/Android/
1013850        /data/misc/profiles/cur/0/
1109311        /storage/emulated/0/Android/
1602419        /data/misc/profiles/ref/
3294944        /data/user_de/10/
10283019       /data/user/10/
86048161       /data/user_de/0/
252376438      /data/dalvik-cache/
1537995332     /data/app
1817762284     /data/user/0/
3713029805
```

It's 3.7 GB, leaving only 250 MB behind, some of which is taken by the `/sdcard` of other two user profiles (`/data/media/<user_id>`). The rest is used by system logs and configuration files, particularly in `/data/system*` and `/data/misc*` directories.

This system usage is shown as "System" which excludes shared storage size <sup>([5][17], [6][18])</sup>. Some figures differ from Android but after all we know how the space is actually used, and where it's being wasted.

---

**RELATED:**

- [Android's Storage Journey][19]


  [1]: https://developer.android.com/training/data-storage/files/external
  [2]: https://android.googlesource.com/platform/frameworks/native/+/refs/tags/android-9.0.0_r47/cmds/installd/InstalldNativeService.cpp#1819
  [3]: https://android.googlesource.com/platform/frameworks/native/+/refs/tags/android-9.0.0_r47/cmds/installd/MatchExtensionGen.h
  [4]: https://android.stackexchange.com/a/210294/218526
  [5]: https://forum.xda-developers.com/android/general/info-android-device-partitions-basic-t3586565
  [6]: https://android.stackexchange.com/a/205494/218526
  [7]: https://unix.stackexchange.com/a/120312/262728
  [8]: https://android.googlesource.com/platform/frameworks/base/+/refs/tags/android-9.0.0_r47/core/java/android/os/FileUtils.java#1036
  [9]: https://android.googlesource.com/platform/frameworks/base/+/refs/tags/android-9.0.0_r47/core/java/android/os/storage/StorageManager.java#1127
  [10]: https://android.googlesource.com/platform/packages/apps/Settings/+/refs/tags/android-9.0.0_r47/src/com/android/settings/deviceinfo/storage/StorageAsyncLoader.java#102
  [11]: https://android.googlesource.com/platform/frameworks/base/+/refs/tags/android-9.0.0_r47/packages/SettingsLib/src/com/android/settingslib/applications/StorageStatsSource.java#54
  [12]: https://android.googlesource.com/platform/frameworks/base/+/refs/tags/android-9.0.0_r47/services/usage/java/com/android/server/usage/StorageStatsService.java#289
  [13]: https://android.googlesource.com/platform/frameworks/native/+/refs/tags/android-9.0.0_r47/cmds/installd/InstalldNativeService.cpp#1431
  [14]: https://android.googlesource.com/platform/frameworks/base/+/refs/tags/android-9.0.0_r47/services/usage/java/com/android/server/usage/StorageStatsService.java#281
  [15]: https://source.android.com/devices/tech/ota/ab/ab_faqs#how-did-you-halve-the-size-of-the-system-partition-without-squashfs
  [16]: https://android.stackexchange.com/a/218507/218526
  [17]: https://android.googlesource.com/platform/packages/apps/Settings/+/refs/tags/android-9.0.0_r47/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java#159
  [18]: https://android.googlesource.com/platform/frameworks/base/+/refs/tags/android-9.0.0_r47/services/core/java/com/android/server/storage/FileCollector.java#213
  [19]: https://android.stackexchange.com/a/218469/218526