我试图保存一些设置,但我正在遵循的教程(android教程)没有帮助,因为我被困在第一行代码,因为它似乎monodroid不同吗?
select your mode to be either private or public.
int mode= Activity.MODE.PRIVATE;
// get the sharedPreference of your context.
SharedPreference s mySharedPreferences ; mySharedPreferences=getSharedPreferences(“Name_of_your_preference”,mode);
// retrieve an editor to modify the shared preferences
SharedPreferences.Editor editor= mySharedPreferences.edit();
/* now store your primitive type values. In this case it is true, 1f and Hello! World */
editor.putBolean(“myBoolean”,true);
editor.putFloat(“myFloat”,1f);
editor.putString(“myString”,” Hello! World”);
//save the changes that you made
editor.commit();
Run Code Online (Sandbox Code Playgroud)
我没有Activity.MODE.PRIVATE;在monodroid中看到.
这是我的功能:
protected void SaveSetting(string name, string value)
{
var prefences = GetSharedPreferences(Consts.Application.SETTINGS_FILE, FileCreationMode.Private);
var editor = prefences.Edit();
editor.Remove(name);
editor.PutString(name, value);
editor.Commit();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2109 次 |
| 最近记录: |