Android - Sharedpreferences - App Update [Doubt]

Asked

Viewed 42 times

1

I have a software program in version 9.0.8 and in this version I added a Sharedpreference that stores a value corresponding to the current version of the app to perform some tasks.

When I upgrade this program to version 9.0.9 on a device that contained version 9.0.8, the tag corresponding to the version value (9.0.8) will remain saved in the device’s memory?

  • 1

    Sharedpreferences is designed to store information from the application, not from its version, so we would have to log in every update to an application if it stores user information. So changing version does not change the stored data at all.

  • I would store the current version of the app to automate some tasks, this scan would be done only once, so capturing the App version would be useful in my case.

  • 1

    Well, then you will have to check when starting the main Activity, which will be started when starting the app, which will search for Buildconfig and compare with the information in Sharedpreference.

  • Thank you so much for helping Assisi.

  • You’re welcome Pedro, I hope I helped.

1 answer

0

Then she will be saved yes, but there may be some unknown error and she will not be saved. With me this never occurred on new Pis.

You have to take into account the same package name, and also the same name assigned to sharedpreferences.

From Api 23 it is possible to explicitly leave the backup of the data to include in the manifest, inside application:

android:allowBackup="true"

Browser other questions tagged

You are not signed in. Login or sign up in order to post.