Search code examples
androidsharedpreferencesalarmmanager

Does updating app clear sharedpreferences or remove alarms set by the app?


I've published my app in google store and now I want to update it.

But I want to be assured that I don't lose stored data in my app shared preferences. I also set some alarm in my app which starts notification, and I don't want to lose them either.

I'm not sure how updating app works? does it rewrite these things? Is there anyway that I can test it before I globally publish it?

I should mention that the changes I made in this version contain some changes in manifest: I changed targetSdkVersion and minSdkVersion (It used to have minSdk=8 now I've changed it to 4 and added targetsdk=15) and I gave a process name to my alarmservice (which is an intentservice to set the alarm) but then decided to change it and it doesn't have a processname now.


Solution

  • Normally, the SharedPreferences(as well as other user data) will be kept during the update process, but sometimes, due to some "unknown" problem, the data may get lost, and I guess it is out of your control. So, you can simply believe that the SharedPreferences will be kept.

    As for alarms, how did you set these alarms? If you set them in code, it should be 100% ok as long as you set them right in code.

    Of course, the best way to test is install your updated app on your device before you push it up to the market. First, you should install your market version of app on your phone, then export your app with your market keystore on your local computer, finally, install the exported version on your phone(the installer should inform you about the update). And you can check if these settings are still there.

    While exporting, the most important thing is to make sure you are using the same keystore as you use with the market version of app.

    Hope this will help you.