0

In an android application, what is the best method to store primitive data variables (such as a list of 3 integers) on the device so that those integers can be seen and manipulated by the app, but remain on the device after updating the app?

also, it would be best if there was a way to tell the difference between the user updating and uninstalling and delete the file upon the latter. Any easy way to do this that i'm unaware of?

Any example code of the actual serializing of a piece of data would be very helpful.

I'm reading the documentation, but having trouble finding really clear examples.

cody
  • 735
  • 3
  • 11
  • 19
  • Are you aware of the [SharedPreferences](http://developer.android.com/guide/topics/data/data-storage.html#pref)? –  Nov 25 '11 at 21:38
  • I've been looking at that, but it doesn't specify in the documentation how persistent the data is. Will Shared Preferences persist after updating the app? Internal Storage specifically says that files are deleted at uninstall. I guess my question is more about that. – cody Nov 25 '11 at 22:03
  • 1
    Yes, the SharedPreferences will persist with every app update, as already answered [here](http://stackoverflow.com/questions/3860823/are-shared-preferences-in-android-apps-deleted-when-a-user-updates-the-app). In the early days there used be an [issue](http://code.google.com/p/android/issues/detail?id=2066) in combination with forward lock/copy protection, but that was fixed in 1.5. – MH. Nov 25 '11 at 22:17

1 Answers1

0

Refer here!

Tapan Thaker
  • 362
  • 5
  • 13
  • I won't downvote this since you are new to StackOverflow, but: [Answers that contain only a link are bad](http://meta.stackexchange.com/questions/8231/are-answers-that-just-contain-links-elsewhere-really-good-answers). Please give at least a small summary what the answer in the link is and add it for further information. Also please [label links with something else than "here"](http://ux.stackexchange.com/questions/12100/why-shouldnt-we-use-the-word-here-in-a-textlink), so that interested people have an idea where they go when they click the link. Thanks. –  Nov 26 '11 at 13:29
  • And also add that this is your very own blog when you link to it for reasons of transparency. –  Nov 26 '11 at 13:32