Android uses a file system that's similar to disk-based file systems on other platforms. There's a specific way how to perform read and write on files within Android file system using the File APIs.
Android uses a file system that's similar to disk-based file systems on other platforms. There's a specific way how to perform read and write on files within Android file system using the File APIs.
All Android devices have two file storage areas: "internal" and "external" storage. These names come from the early days of Android, when most devices offered built-in non-volatile memory (internal storage), plus a removable storage medium such as a micro SD card (external storage). Many devices now divide the permanent storage space into separate "internal" and "external" partitions. So even without a removable storage medium, these two storage spaces always exist, and the API behavior is the same regardless of whether the external storage is removable.
Because the external storage might be removable, there are some differences between these two options as follows.
Internal storage:
- It's always available.
- Files saved here are accessible by only your app.
- When the user uninstalls your app, the system removes all your app's files from internal storage.
Internal storage is best when you want to be sure that neither the user nor other apps can access your files.
External storage:
- It's not always available, because the user can mount the external storage as USB storage and in some cases remove it from the device.
- It's world-readable, so files saved here may be read outside of your control.
- When the user uninstalls your app, the system removes your app's
files from here only if you save them in the directory from
getExternalFilesDir()
.
External storage is the best place for files that don't require access restrictions and for files that you want to share with other apps or allow the user to access with a computer.
And all of the mentioned two variants of data/file storage within Android involves various other techniques related to Permissions within the Android System which the developers has to write code in order to handle it smoothly without interrupting the end user actions.
Other than the above two areas it involves few other ways of Data Storage within Android systems such as shared-preferences and databases, but that's not relevant to our tag Android-storage
.
Some parts of this description was excerpts from following article from Android developer documents: https://developer.android.com/training/data-storage/files