Data and file storage overview
Android uses a file system that's similar to disk-based file systems on other
platforms. The system provides several options for you to save your app data:
App-specific storage: Store files that are meant for your app's use only, either in
dedicated directories within an internal storage volume or different dedicated
directories within external storage. Use the directories within internal storage to
save sensitive information that other apps shouldn't access.
Shared storage: Store files that your app intends to share with other apps,
including media, documents, and other files.
Preferences: Store private, primitive data in key-value pairs.
Databases: Store structured data in a private database using the Room persistence
library.
The characteristics of these options are summarized in the following table:
Type of content Access method Permissions needed
App- Files meant for your From internal storage, getFilesDir() or getCacheDir() Never needed for internal stora
specific app's use only
files From external Not needed for external storag
storage, getExternalFilesDir() or getExternalCacheDi your app is used on devices tha
r() Android 4.4 (API level 19) or hig
Media Shareable media files
(images, audio files,
videos)
Documents and other Other types of shareable content, including Storage Access Non
files downloaded files Framework
App preferences Key-value pairs Jetpack Non
Preferences library
Database Structured data Room persistence