Application Data & Files
Last updated
Last updated
Android uses a file system that's similar to disk-based file systems on other platforms. The system provides several options for saving app data:
App-specific storage - internal storage to saving sensitive information that other apps should not be able to access.
Shared storage - storage for files that the app shares with other apps, including media, documents, and other files.
Preferences - storage for private, primitive data in key-value pairs.
Databases - storage for structured data in a private database using the Room persistence library.
Type of content | Access method | Permissions needed | |
---|---|---|---|
App-specific files
From internal storage, getFilesDir() and getCacheDir()
From external storage, getExternalFilesDir() and getExternalCacheDir()
Never needed for internal storage
Not needed for external storage when your app is used on devices that run Android 4.4 (API level 19) or higher
Shareable media files (images, audio files, videos)
MediaStore API
READ_EXTERNAL_STORAGE when accessing other apps' files on Android 11 (API level 30) or higher
READ_EXTERNAL_STORAGE or WRITE_EXTERNAL_STORAGE when accessing other apps' files on Android 10 (API level 29)
Permissions are required for all files on Android 9 (API level 28) or lower
Other types of shareable content, including downloaded files
Storage Access Framework
None
Key-value pairs
Jetpack Preferences library
None
Database
Structured data
Room persistence library
None