SoFunction
Updated on 2025-03-01

Detailed explanation of how Android implements permanent data storage

background:
According to the data storage method in Android, it can be divided into the following types
Content Provider (used SQLite implementation), SQLite, SharedPreferences (used XML implementation), files, networks, etc.

Today in the project, you need to make a permanently saved data and save it locally.
So I tested these saving methods.
Among them: SharedPreferences, SQLite, Content Provider will delete the file when [Settings]-[Application Management]--click [Clear Data]. So it's not safe.
File system: If the SD card is broken or unplugged, data will also be lost.

Solution:
Save data to the SD card (considering that the SD card can save various complex data and its capacity is larger than other storage methods),
To obtain data, first go to the SD card to obtain it, and if there is no online data to save it locally.