Missing sharedPreferences after application reinstall

Hello,

I've got problem with sharedPreference for Android application developed in Visual Studio.
Each time I've change my code and rebuild the project and start to debug application, sharedPreference settings are lost.

I expected that those settings will be accessable after reinstall.

When I use sharedPreference to store my value and then close down my application. After reopen my app settings are loaded correctly.

I'm using this code:

public string LastLogin
{
set
{
sharedPreference.Edit().PutString(ConstLastLogin, value).Commit();
}
get
{
return sharedPreference.GetString(ConstLastLogin, "");
}
}

where for sharedPreference I used several methods:

sharedPreference = PreferenceManager.GetDefaultSharedPreferences(Application.Context);

OR

sharedPreference = context.ApplicationContext.GetSharedPreferences("WMS", FileCreationMode.Private);

How to keep this settings after reinstall?

Posts

  • RaphaelSchindlerRaphaelSchindler USMember ✭✭✭

    You do know that the application is reinstalled every time if you don't activate the fast deployment option?

  • Jacek.6393Jacek.6393 USMember

    I actually know that : )
    What I didn't known was 'Preserve application data/cache on device between deploys' option.
    Since I've checked it my application setting are keeped after reinstall.

  • RaphaelSchindlerRaphaelSchindler USMember ✭✭✭

    Good to hear :)

Sign In or Register to comment.