List of usage examples for android.content SharedPreferences edit
Editor edit();
From source file:Main.java
public static void saveMaxIndex(Context mContext, int maxIndex) { SharedPreferences settings = mContext.getSharedPreferences("clock", Context.MODE_PRIVATE); Editor mEditor = settings.edit(); mEditor.putInt(MAX_INDEX, maxIndex); mEditor.commit();/*from w w w . ja va 2 s.co m*/ }
From source file:Main.java
public static boolean saveUrl(Context context, String key, String value) { SharedPreferences preferences = getSharedPreference(context); SharedPreferences.Editor editor = preferences.edit(); editor.putString(key, value);//from w w w . ja va 2 s .co m return editor.commit(); }
From source file:Main.java
public static void SetMetricSystem(Activity a, boolean value) { SharedPreferences sp = a.getSharedPreferences(FILE_KEY, Activity.MODE_PRIVATE); SharedPreferences.Editor ed = sp.edit(); ed.putBoolean(METRIC_KEY, value);//from w w w.j a v a 2s . c om ed.commit(); }
From source file:Main.java
public static void SetWendlerMax(Activity a, boolean value) { SharedPreferences sp = a.getSharedPreferences(FILE_KEY, Activity.MODE_PRIVATE); SharedPreferences.Editor ed = sp.edit(); ed.putBoolean(WENDLER_KEY, value);// w w w. j a v a 2 s . c o m ed.commit(); }
From source file:Main.java
/** * Method to set the new assumed Mode of the active session * /* w ww . j a v a 2s. c o m*/ * @param context * @param mode The new assumed Mode of the active session */ public static void setActiveSessionMode(Context context, int mode) { SharedPreferences prefs = context.getSharedPreferences(context.getPackageName(), Context.MODE_PRIVATE); prefs.edit().putInt(PREFS_KEY_MODE, mode).commit(); }
From source file:Main.java
public static void setFirstByTag(String tag, Context context) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences.Editor editor = sp.edit(); editor.putBoolean(tag, false);//from ww w .j ava 2 s . co m editor.commit(); }
From source file:Main.java
public static Boolean putObject(String preName, Context context, String key, Class<?> clazz, Object obj) { String str = new Gson().toJson(obj, clazz); SharedPreferences pre = context.getSharedPreferences(preName, Context.MODE_PRIVATE); Editor editor = pre.edit(); editor.putString(key, str);/*w ww. j av a 2s .c o m*/ return editor.commit(); }
From source file:Main.java
public static void delObject(Context context, String key) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences.Editor editor = sp.edit(); editor.remove(key);/*from w ww .j a va2 s . c o m*/ editor.commit(); }
From source file:Main.java
public static void updateConfig(Context context) { SharedPreferences sp = getSP(context); SharedPreferences.Editor editor = sp.edit(); PackageManager pm = context.getPackageManager(); if (!sp.contains(APP_ACTIVE_TIME)) { editor.putLong(APP_ACTIVE_TIME, System.currentTimeMillis()); editor.putBoolean(APP_IS_UPDATE, false); } else {/*from www .j a v a 2 s .co m*/ editor.putBoolean(APP_IS_UPDATE, true); } try { PackageInfo info = pm.getPackageInfo(context.getPackageName(), 0); String versionName = info.versionName; editor.putString(APP_LAST_VERSION, versionName); } catch (PackageManager.NameNotFoundException e) { } editor.apply(); }
From source file:Main.java
public static void setLogText(Context context, String text) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences.Editor editor = sp.edit(); editor.putString("log_text", text); editor.commit();/* w ww . java2 s .co m*/ }