public virtual void SetCurrentUserId(string id) { SharedPreferences sp = PreferenceManager.GetDefaultSharedPreferences(GetApplicationContext ()); if (id != null) { sp.Edit().PutString(PrefCurrentUserId, id).Apply(); } else { sp.Edit().Remove(PrefCurrentUserId).Apply(); } }
public MvxAndroidSettings() { SharedPreferences = PreferenceManager.GetDefaultSharedPreferences(Application.Context); SharedPreferencesEditor = SharedPreferences.Edit(); SecuredPreferences = Application.Context.GetSharedPreferences(Application.Context.PackageName + ".SecureStorage", FileCreationMode.Private); SecuredPreferencesEditor = SecuredPreferences.Edit(); }
// =========================================================== // Methods // =========================================================== public bool IsFirstTime(/* final */ String pKey) { /* final */ SharedPreferences prefs = this.GetPreferences(FileCreationMode.Private); if (prefs.GetBoolean(pKey, true)) { prefs.Edit().PutBoolean(pKey, false).Commit(); return(true); } return(false); }
public bool IsAppUpdated() { int ver = GetVersionCode(); if (ver > SharedPreferences.GetInt("version", 0)) { SharedPreferences.Edit().PutInt("version", ver).Commit(); return(true); } else { return(false); } }
public MainApp(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer) { Instance = this; SharedPreferences = PreferenceManager.GetDefaultSharedPreferences(ApplicationContext); GraphSaverLoader = new Graph.SaverLoader(new AssetsProvider(ApplicationContext)); if (IsAppUpdated()) { var groupName = SharedPreferences.GetString("groupnumber", "-1"); var dictionary = Instance.GroupsDictionary.Task.Result; if (dictionary.TryGetValue(groupName, out int id)) { SharedPreferences.Edit().PutInt("groupid", id).Apply(); } } }
// =========================================================== // Constructors // =========================================================== public void OnCreate(/* final */ Bundle savedInstanceState) { base.OnCreate(savedInstanceState); this.SetContentView(R.Layout.list_examples); this.mExpandableExampleLauncherListAdapter = new ExpandableExampleLauncherListAdapter(this); this.SetListAdapter(this.mExpandableExampleLauncherListAdapter); /* TODO: Consider re-adding this if we * this.findViewById(R.id.btn_get_involved).setOnClickListener(new OnClickListener() { * @Override * public void onClick(final View pView) { * ExampleLauncher.this.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.andengine.org"))); * } * }); */ /* final */ SharedPreferences prefs = this.GetPreferences(FileCreationMode.Private); this.mVersionCodeCurrent = this.GetVersionCode(); this.mVersionCodeLastLaunch = prefs.GetInt(PREF_LAST_APP_LAUNCH_VERSIONCODE_ID, -1); if (this.IsFirstTime("first.app.launch")) { this.ShowDialog(DIALOG_FIRST_APP_LAUNCH); } else if (this.mVersionCodeLastLaunch != -1 && this.mVersionCodeLastLaunch < this.mVersionCodeCurrent) { this.ShowDialog(DIALOG_NEW_IN_THIS_VERSION); } else if (IsFirstTime("please.submit.benchmarks")) { this.ShowDialog(DIALOG_BENCHMARKS_SUBMIT_PLEASE); } prefs.Edit().PutInt(PREF_LAST_APP_LAUNCH_VERSIONCODE_ID, this.mVersionCodeCurrent).Commit(); }
public SettingsHelper() { SharedPreferences = PreferenceManager.GetDefaultSharedPreferences(Application.Context); SharedPreferencesEditor = SharedPreferences.Edit(); }
public AndroidUserPreferences() { SharedPreferences = PreferenceManager.GetDefaultSharedPreferences(Application.Context); SharedPreferencesEditor = SharedPreferences.Edit(); }
public static void SetInt(string key, int value) { SharedPreferences.Edit().PutInt(key, value).Commit(); }