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); } }
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)); }