Use Shared Preferences in xamarin [closed]

不想你离开。 提交于 2020-01-01 18:44:50

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/25082199/use-shared-preferences-in-xamarin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!