How to save general preference data after clearing app cache from settings
It's worth noting that there are three types of data cleansing in Android, of which your application has no control:
- Clear data
- Clear cache
- Clear defaults
The only way to have persistent data is to use an SD card, but again, users will not like having data on their card after uninstalling the app, or users can remove the SD card.
Or, you might consider:
- Storing data on a remote server with some kind of authentication to get it
- Using Data Backup Service
source to share
General preferences are commonly used to store temporary information on a user's device. Thus, in general, it contains temporary information / data.
To store the data to be aged in the Clear Cache action, you can store the information in a sqlite database.
To do this, you need to implement a content provider that will encapsulate sqllite database access, this will help you store and retrieve data that will not be deleted when clearing the cache. find more information on how to create a content provider here: http://developer.android.com/training/basics/data-storage/databases.html
source to share