Could you list all the possible directories where Android apps may store data? Can you also provide description of the kind of data stored in each directory?
-
1See also: List of special Android SD card folders? / Is it possible to reorganize the SD card? Because it is a mess in there / Which directories can I remove in internal SD? / Check what storage an app uses?– GAThrawnCommented Jun 25, 2013 at 13:06
-
Plus Android Folder Hiearchy / Where on the file system are SMS messages stored? / Where in the file system are applications installed?– IzzyCommented Jun 25, 2013 at 15:33
3 Answers
All apps (root or not) have a default data directory, which is /data/data/<package_name>
. By default, the apps databases, settings, and all other data go here. This directory is "private" to the app – which means no other app and not even the user can access data in it (without root permissions).
If an app expects huge amounts of data to be stored, or for other reasons wants to "be nice to internal storage", there's a corresponding directory on the SDCard (Android/data/<package_name>
).
Apart from that, all apps can store data anywhere on the SDCard, as there are no restrictions -- and many apps do so. They can use directory names freely (and they again do), which is what often makes it hard to decide what all that "junk" on the card is intended for, and what of it can be deleted.
Though, as Tom pointed out, root-apps could store their data almost everywhere on your device, they usually follow the same rules as other apps.
You can find a general explanation of the Android directory hierarchy in my answer here. For your specific question I might add some more details on the /data/data/<package_name>
(and corresponding SD-part):
databases/
: here go the app's databaseslib/
: libraries and helpers for the appfiles/
: other related filesshared_prefs/
: preferences and settingscache/
: well, caches
There might be several more directories in this place, or fewer -- it all depends on the app. In its own "home directory" (and that's what it basically is, spoken Linux-wise) they can place files where they want. Usually, these files and directories are only accessible by the app itself (and root, of course) -- other than those stored on the SDCard, which are accessible by all apps.
-
Comments are not for extended discussion; this conversation has been moved to chat.– Andrew T. ♦Commented Dec 11, 2020 at 12:58
-
2
Some major changes occurred to storage in Android 4.4 (see Android's Storage Journey). So, the following is generally true for Android 4.4+ and particularly 6+.
This is from my detailed answer to How disk space is used on Android device?. Apps' files are saved (by the system and the app itself) to internal and external storage under different categories.
Directory | Description/API |
---|---|
App code | |
/data/app/<pkg>* |
(user apps installation directory) |
/data/app/<pkg>*/base.apk |
(original .apk file) |
/data/app/<pkg>*/lib/<arch>/*.so |
(shared libraries) |
/data/app/<pkg>*/oat/<arch>/base.[art|odex|vdex] |
(compiled executable code) |
/data/dalvik-cache/<arch>/*.[art|dex|oat|vdex] |
(compiled executable code, only for system apps) |
/data/misc/profiles/cur/<user_id>/<pkg>/primary.prof |
(ART profile) |
/data/misc/profiles/ref/<pkg>/primary.prof |
(ART profile) |
Internal storage | |
/data/user[_de]/<user_id>/<pkg> |
getDataDir |
/data/user[_de]/<user_id>/<pkg>/files |
getFilesDir |
/data/user[_de]/<user_id>/<pkg>/[code_]cache |
getCacheDir or getCodeCacheDir |
/data/user[_de]/<user_id>/<pkg>/databases |
getDatabasePath |
/data/user[_de]/<user_id>/<pkg>/no_backup |
getNoBackupFilesDir |
/data/user[_de]/<user_id>/<pkg>/shared_prefs |
getSharedPreferences |
External storage | |
/storage/emulated/obb/<pkg>/*.obb |
(shared by multi-users, exposed in following view) |
/storage/emulated/<user_id>/Android/obb/<pkg>/*.<pkg>.obb |
getObbDirs |
/storage/emulated/<user_id>/Android/media/<pkg> |
getExternalMediaDirs |
/storage/emulated/<user_id>/Android/data/<pkg>/ |
getExternalFilesDirs |
/storage/emulated/<user_id>/Android/data/<pkg>/files |
getExternalFilesDirs |
/storage/emulated/<user_id>/Android/data/<pkg>/[code_]cache |
getExternalCacheDirs |
All of the above paths on internal and external storage (primary and secondary) are the app's private directories which are accessible to the respective app without requesting any permission. Apps can also create other directories (not explicitly available through APIs) in their private storage. All of these directories belonging to an app are deleted when the app is uninstalled.
Additionally, apps can put their data anywhere on primary external storage (including some standard directories and other apps' private directories) if
WRITE_EXTERNAL_STORAGE
permission is granted (getExternalStorageDirectory
returns/storage/emulated/<user_id>
). For secondary external storage and removable storage, SAF is used. See details in How to save files to external SD card?.However, in Android 10, writing directly to primary external shared storage is deprecated (
getExternalStorageDirectory
andgetExternalStoragePublicDirectory
are no more available). Apps need to use one of Android's built-in content providers; either MediaStore (for media files) or SAF (for any other type of files)./data
paths may get replaced with/mnt/expand/[UUID]
when using Adoptable Storage./storage/emulated
gets replaced with/storage/[UUID]
when using secondary external storage (like an SD card).For multiple users/profiles,
<user_id>
is different, the device owner is always0
./data/user/0
is a symlink to/data/data
for historical reasons. Secondary external storage is only available to the device owner.OBB directory is shared among users/profiles (up to Android 9) to save space. FUSE/
sdcardfs
always exposes/storage/emulated/obb
as/storage/emulated/<user_id>/Android/obb
./data/user_de
is the Device Encrypted storage on FBE devices which lets certain apps run on boot without asking for user credentials./data/misc/profiles
are used by ART for profile-guided compilation of app code.Description of each directory is somewhat evident from names, details can be seen in API documentation.
Caches are cleared by OS when running low on storage, keeping apps exceeding the allotted quota on top.
Apps' private
files
directories in external storage aren't automatically scanned by MediaScanner butmedia
directories are.Caches and
no_backup
directories are not backed up to the cloud. See official documentation.
-
Where is
/data
? Not found in windows explorer displaying the internal storage when connected the android phone to PC.– zwcloudCommented Sep 24, 2021 at 4:16 -
5@zwcloud See How disk space is used on Android device? and Why are superuser permissions needed to acess /data partition? Commented Sep 24, 2021 at 4:35
The answer to your question you are asking is too big. I can, however, give you a basic answer which covers the basics.
There are two kinds of apps:
Root and non-root.
Root apps can basically store/modify files wherever they want.
Non-root apps can only store/modify files here: /sdcard/
and every folder what comes after.
Mostly, the installed apps store themselves at /sdcard/Android/data
or /sdcard/Android/obb
.
Some apps store their save games/configuration data files on /sdcard/APPNAME/
, or just on the /sdcard/
To be able to use root apps, you'll need to have rooted your Android device and have given permission from one of the superuser apps.