Search code examples
xamarinxamarin.formsgoogle-playpreferences

Xamarin forms Preferences reset when app update


I'm using Preferences to save service IP but when i update app this values reset.

Preferences.Set("myServiceIP", serviceIP);

I take a new apk from visual studio and install to my phone then these preferences reset. I need to save at least this service IP. I want to learn this when i install my app from Google Play and update from Google Play these preferences reset or keep at this situation ? If update won't reset my preferences from my device its ok but if this reset also, this going to be problem. Can someone give me information about this ?


Solution

  • As a summary, I will post an answer.

    From document Xamarin.Essentials: Preferences, we could find that:

    Uninstalling the application will cause all Preferences to be removed, with the exception being apps that target and run on Android 6.0 (API level 23) or later that use Auto Backup. This feature is on by default and preserves app data including Shared Preferences, which is what the Preferences API utilizes.

    So, if you uninstall your app, this value of preferences will delete. If you didn't uninstall your app and update your app directly, the previous Preferences data will be kept. Whether the stored value changes depends on whether you reset the value of variable serviceIP that you want to store to Preferences.