由于项目需要 要保持用户登录状态 要进行状态保持 用途就好像asp.net的session一样
登录的时候进行保存
1
2
3
4
5
6
|
<br>ISharedPreferences shared = GetSharedPreferences( "UserName" , FileCreationMode.Private);<br>
string
value = shared.GetString( "UserName" , "" );
value = "new value" ;
ISharedPreferencesEditor editor = shared.Edit();
editor.PutString( "UserName" ·,value);
editor.Commit();
|
在其他页面进行读取
1
2
|
ISharedPreferences shared = GetSharedPreferences( "UserName" , FileCreationMode.Private);
string
value = shared.GetString( "UserName" , "" );
|
很简单好用