Xamarin.Forms - Read SharedPreferences of old version apk

andreMetal 46 Reputation points
2021-01-19T09:22:56.233+00:00

Hello, this is my situation: I have an Android application written in java using Android Studio already distributed in the store. Recently with my team we decide to rewrite the app using Xamarin.Forms. The old version app used SharedPreferences to store and read some settings. We tried to read the same setting with the new xamarin forms version without success. My first question is: is it possible to do what we are trying to? If yes, is there a good way to do?
Thanks in advance for the reply.

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,326 questions
{count} votes

Accepted answer
  1. JarvanZhang 23,951 Reputation points
    2021-01-20T09:22:15.48+00:00

    Hello,​

    Welcome to our Microsoft Q&A platform!

    Hi, AndreaTizzoni-0935. I created a basic sample to test the function in debug mode, the data which is saved in as cannot be get in Xamarin. It seems that it uninstall the java version and install xamarin version instead of overwriting the previous version.

    update

    This will work fine in release mode, installing the c# version application with the same keystore of the java app will make it.

    Best Regards,

    Jarvan Zhang


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


1 additional answer

Sort by: Most helpful
  1. Alessandro Caliaro 4,181 Reputation points
    2021-01-19T12:06:29.1+00:00

    https://stackoverflow.com/questions/26668509/how-do-i-use-sharedpreferences-in-xamarin-android

    Take a look to this.
    I see also a

            mSharedPrefs = PreferenceManager.GetDefaultSharedPreferences(mContext);
    

    that seems you are not using