0

Edited:

My search only yields results about how to not erase SharedPreferences or how to edit the preferences with some new value (like blank/null/0)

During my updates, some variables are renamed/replaced/moved...

So, suppose a update change, how do I enforce the google play updates request data changes on the preferences? I want that the user does not input old content if it exists, but, given a state that the whole prefference is to be dropped.

Example:

v1 "MainActivity".prefference = String "Name" Boolean "something"

v2 "MainActivity".prefference = String "Name" Char "something"

So, on update v2, the whole prefference should be maintained while something is to be dropped, then readded.

Using Intent."ACTION_PACKAGE_REPLACED" then manually erasing everything on the application seems to be the way to go, as a "quick-fix", however is there a way to request that the application be uninstalled (and therefore any non-hard-disk files be forgotten), then installed again, and then requested to be run?

As far as I can tell, on Kitkat and above, new installs must be manually opened.

My project is currently on Beta phase, and updates here should be common. What I want is to ensure that the logs I receive are all the latest BUT if the application is not updated, then the log should have its old content...

Bonatti
  • 2,778
  • 5
  • 23
  • 42
  • possible duplicate of [Deleting shared preferences](http://stackoverflow.com/questions/3687315/deleting-shared-preferences) – Nanoc Sep 25 '15 at 12:16
  • @Nanoc While it seems duplicated, I do not want to delete the data. What I want is have some events that request uninstall and reinstall (to simulate a new Install) or some way that requests the data to be dropped. BUT, I want some events to drop, and some events to NOT drop the content... so I dont have to keep track of what data is/was set. – Bonatti Sep 25 '15 at 12:19
  • So in case of a event that should drop data you can use that, otherwise dont use it... are you asking for a way to know if the app has been updated since last execution? – Nanoc Sep 25 '15 at 12:31
  • @Nanoc Perhaps. I am unsure how to follow up here. Basically, I have been setting variables in preferences, then retrieving back. But, if it was a boolean, and now is something else, it will always return the default value (since a boolean is never a String)... what I want is, if a prefference value type was changed, I want to drop just that value. Overwritting has not solved what I want (so `.getBoolean("isGPSready",false)` is always false, when "isGPSready" might have been set as something else like `int`.... at the same time, I do not want user to rewritte all preference on each update – Bonatti Sep 25 '15 at 12:50

0 Answers0