Sunday, October 16, 2022

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

Issue

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:

  • Clear Data
  • Clear Cache
  • Clear Defaults

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


Answered By - Kartheek
Answer Checked By - Willingham (PHPFixing Volunteer)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.