Does updating app clear sharedpreferences or remov

2019-02-17 14:39发布

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.

2条回答
我欲成王,谁敢阻挡
2楼-- · 2019-02-17 15:15

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.

查看更多
【Aperson】
3楼-- · 2019-02-17 15:19

SharedPreferences are stored and will survive updating the application. About the alarms I am not sure, sorry.

For testing your update simply install your market version on your device, set up your stuff (alarms, sharedprefs) like a normal user would do and just install the apk on your phone that you would upload to the market (signed apk!). The installing should be the same as the update your user will get...

查看更多
登录 后发表回答