0

When I update application through popup implemented in application code on change of version shared preference persist but when update using auto-update or from updates available in play store shared preferences got removed?

  • What's your question? – Marcus Feb 16 '15 at 11:55
  • Simply adding a `?` at the end of a sentence doesn't make it a question - you have to be more specific. Provide code examples, describe your problem and what you've currently done. – Marcus Feb 16 '15 at 12:02
  • I am trying to show popup in my application when there is version update and give 2 option either to update and skip so when user click on update play store will open and user can update the application and after update on reopen user got auto login into application due to data(username) persist in shared preference but this doesn't happens when auto-login option is on and when update through updates available in play -store. – Karan Garg Feb 16 '15 at 12:12
  • I see. The problem is that SharedPreferences doesn't persist when a user uninstalls (or in your case update then re-install) an application. If you want to persist data outside of the application that persists even after uninstall, you will have to use an external server or service. – Marcus Feb 16 '15 at 12:14
  • I am wondering about that, usually, by only updating the app through playstore with deinstalling it before, the shared prefeences should persist. – Opiatefuchs Feb 16 '15 at 12:20
  • @marcus... i am only updating the app not reinstalling even in that case not able to find shared preference....but when update through code flow by forcefully deviating user to play store shared preference persist. – Karan Garg Feb 16 '15 at 12:33

1 Answers1

0

You should have a look at SharedPreferencesBackupHelper. Simply put, it backs up your SharedPreference data when ever your app is uninstalled, or when ever you would like to back up your SharedPreferences.

Additionally, this question also addresses your specific problem.

To manually request a restore, you call the requestRestore() method. See this for reference.

Restore the calling application from backup. The data will be restored from the current backup dataset if the application has stored data there, or from the dataset used during the last full device setup operation if the current backup dataset has no matching data. If no backup data exists for this application in either source, a nonzero value will be returned.

Community
  • 1
  • 1
Marcus
  • 6,697
  • 11
  • 46
  • 89