kipo kipo - 2 months ago 31
Android Question

Use Shared Preferences in xamarin

I tried to save string value after the app closed and re open.

I look at all of the SharedPreferences but i didn't understand if i need to open new activity or what.

So if you have any idea it will be very helpful.

Answer

what I recommend that you do is to implement shared preferences... going by this way

SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
        SharedPreferences.Editor editor = preferences.edit();
editor.putstring("PreferenceName","YOUR PREFERENCE VALUE");
editor.commit;

and whenever you want to check the loginMethod value just call the preference value like this...

SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
String myValue= preferences.getString("PreferenceName", "");

if you need more assistant I'll be more than happy to help you

Comments