-2

I have a Native Android App in the Store. This App has its Settings stored in the SharedPreferences. Now I am working on an Update for the App. The Update is a Xamarin Cross-Platform App. App Name, Package Name, and those things are the same as in the Native App. But I can't get the values from SharedPreferences now. Did I make something wrong? I guess it's because of a different Application Context. But I don't know why.

Here is how the Native App is loading the Values:

final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
final Set<String> keySet = prefs.getAll().keySet();

for (final String key : keySet) {
    if (key.startsWith(DatabaseSetting.DATABASE_SETTING_KEY_PREFIX)) {
        //Do stuff
    }
}

After updating the App I can not see any keys in the prefs. C# Xamarin Code to also load these prefs:

ISharedPreferences sharedPrefs = PreferenceManager.GetDefaultSharedPreferences(Application.Context);
foreach (string key in sharedPrefs.All.Keys)
{
  if(key.StartsWith(DATABASE_SETTING_KEY_PREFIX))
}

The App was updated without uninstalling the old one. Just deployed the new one.

M.D.
  • 273
  • 1
  • 5
  • 18

1 Answers1

0
  1. Is it giving you a nullpoint?
  2. Are you storing app context (Android.App.Application.Context) or class context(Context)?
  3. Are there any other exceptions thrown that you possibly aren't catching?
Thabiso Motswagole
  • 146
  • 1
  • 2
  • 17