androidsharedpreferencesclear-cache

How to keep shared preference data after clearing the cache of application from settings


I have observed that when i click on clear cache in settings>apps>particular app, Shared preference data get deleted.

how to keep shared preference data even if i clear the clear the cache? is it possible? if possible means give idea about that


Solution

  • It is worth noting that there are three types of data clearing in Android, of which your application has no control over:

    The only way to have persistent data is to use the SD card, but again, users won't like to have the data on their card after the app is uninstalled or users can un-mount the SD card.

    Or you can consider:

    1. Storing the data on a remote server with some kind of authentication to retrieve it
    2. Using Data Backup service