6

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.

je4d
  • 7,628
  • 32
  • 46
Marjan
  • 123
  • 2
  • 11

2 Answers2

9

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.

Void Main
  • 2,241
  • 3
  • 27
  • 36
  • 1
    Thank you so much. I tested it as you said and my shared preferences and alarm is preserved. :) – Marjan Apr 18 '12 at 11:16
  • 1
    `due to some "unknown" problem, the data may get lost` this is ambiguous! Any references from *documentation*? *Android Team*? – Muhammad Babar Jul 18 '14 at 06:55
  • @MuhammadBabar, nope, it's from my own experience. And, yes, it is ambiguous. I was too busy to trace if the problem was rooted in system bug or my code error, or something else, but the preference was reported lost from one of my users. So, sorry, that's all I can say. – Void Main Jul 18 '14 at 12:42
  • @VoidMain did you tried to contact google android team i mean via bug report? – Muhammad Babar Jul 21 '14 at 06:39
  • @VoidMain if there is actually any problem like this we should report it to get fixed. Because the **unknown problem** data lose is dangerous! – Muhammad Babar Jul 21 '14 at 06:42
  • 1
    @MuhammadBabar, yeah, you are right. But in my defence, I was on really tight schedule back then in late 2011, so I didn't spend much time studying the problem. And it's been 3 years since then, so, the problem is really hard to report anymore. But still, you are right on contacting developer team. Thanks for your suggestion. – Void Main Jul 21 '14 at 12:10
2

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...

WarrenFaith
  • 57,492
  • 25
  • 134
  • 150
  • Thank you so much. I tested it as you said and my shared preferences and alarm is preserved. :) – Marjan Apr 18 '12 at 11:17
  • @WarrenFaith :What if I wanted to clear all the prevouso data in the update? I am adding new tables to the database in the update. The table is not created in code. Just the db is added in the assets. So what I want to do is that the update clear the previous db and replace it with the new one. – Ashwin Oct 04 '12 at 15:23
  • @Ashwin this has nothing to do with the question here, but take a look at the first part of my [answer](http://stackoverflow.com/a/4499476/180538) to another question... Double commenting isn't welcome here, too. – WarrenFaith Oct 05 '12 at 08:34
  • @WarrenFaith : What's double commenting? I Just asked a question more detailed to that of the OP's. – Ashwin Oct 05 '12 at 09:08
  • @Ashwin first there is a difference between SharedPreferences and a SQLite database, so you are off topic here. Second you posted the same comment on both answers -> double comment. Third a comment is not meant to be used to "ask a question more detailed". You should have searched or at least created a separate question for that. – WarrenFaith Oct 05 '12 at 09:13
  • @WarrenFaith : My question was ":What if I wanted to clear all the previous data in the update?". That is basically my question. Data can be referred to both Sharedpreference and SQLite DB. Anyway thanks for the link. – Ashwin Oct 05 '12 at 11:15
  • @Ashwin your question was about a database. You used 4 times "db" or "table". Anyway, I hope you found a solution. – WarrenFaith Oct 05 '12 at 11:17
  • @WarrenFaith : yeah that was just to elaborate. In the first line I had asked the real question :) – Ashwin Oct 05 '12 at 11:20