public static void saveRecords(Android.Content.ISharedPreferences sp) { string jstring = JsonConvert.SerializeObject(myRecords); var editor = sp.Edit(); editor.PutString("records", jstring); editor.Commit(); }
void Abstraction.DependencyServices.ISharedPreferences.SaveString(string pKey, string pValue) { Android.Content.ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(Xamarin.Forms.Forms.Context); ISharedPreferencesEditor editor = prefs.Edit(); editor.PutString(pKey, pValue); editor.Apply(); }
void Abstraction.DependencyServices.ISharedPreferences.RemoveString(string pkey) { Android.Content.ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(Xamarin.Forms.Forms.Context); ISharedPreferencesEditor editor = prefs.Edit(); editor.Remove(pkey); editor.Apply(); }
private int[] GetProgressDrawableColors() { int[] Colors = new int[4]; Android.Content.ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(this); Colors[0] = prefs.GetInt(GetString(Resource.String.firstcolor_pref_key), Resources.GetColor(Resource.Color.red)); Colors[1] = prefs.GetInt(GetString(Resource.String.secondcolor_pref_key), Resources.GetColor(Resource.Color.blue)); Colors[2] = prefs.GetInt(GetString(Resource.String.thirdcolor_pref_key), Resources.GetColor(Resource.Color.yellow)); Colors[3] = prefs.GetInt(GetString(Resource.String.fourthcolor_pref_key), Resources.GetColor(Resource.Color.green)); return(Colors); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.activity_main); twoPlayers = FindViewById <Button>(Resource.Id.btnFirstGameMode); onePlayer = FindViewById <Button>(Resource.Id.btnSecondGameMode); res = FindViewById <Button>(Resource.Id.btnRes); twoPlayers.Click += TwoPlayers_Click; onePlayer.Click += OnePlayer_Click; res.Click += Res_Click;; ll = FindViewById <LinearLayout>(Resource.Id.linearLayout1); sp = this.GetSharedPreferences("details", Android.Content.FileCreationMode.Private); //sp.Edit().Clear(); //sp.Edit().Commit(); string str = sp.GetString("records", null); if (str != null) { Records.initRecords(sp); } }
/// <summary> /// gets the app preferences object from android /// </summary> /// <returns></returns> public static Android.Content.ISharedPreferences GetAppSharedPrefs() { Prefs = Android.App.Application.Context.GetSharedPreferences("BitChute", FileCreationMode.Private); PrefEditor = Prefs.Edit(); return(Prefs); }
public static void initRecords(Android.Content.ISharedPreferences sp) { myRecords = JsonConvert.DeserializeObject <List <MyRecord> >(sp.GetString("records", null)); }
string Abstraction.DependencyServices.ISharedPreferences.GetString(string pKey) { Android.Content.ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(Xamarin.Forms.Forms.Context); return(prefs.GetString(pKey, string.Empty)); }