List of usage examples for android.content SharedPreferences edit
Editor edit();
From source file:Main.java
public static void setLatestQuestionSaved(Context context, String questionUrl) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); Editor edit = prefs.edit(); edit.putString(PREF_LATEST_QUESTION, questionUrl); edit.commit();/* w w w .j av a 2s .c om*/ }
From source file:Main.java
public static void editLight(Context context, boolean isNight) { SharedPreferences preferences = context.getSharedPreferences(APP_THEME_LIGHT, Context.MODE_PRIVATE); preferences.edit().putBoolean(APP_LIGHT_KEY, isNight).commit(); }
From source file:Main.java
public static void setLastForumPageSaved(Context context, int forumPageNum) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); Editor edit = prefs.edit(); edit.putInt(PREF_LAST_FORUM_PAGE_SAVED, forumPageNum); edit.commit();//from www . j a v a2 s. c o m }
From source file:Main.java
public static void setPlusImageUrl(final Context context, final String accountName, final String imageUrl) { SharedPreferences sp = getSharedPreferences(context); sp.edit().putString(makeAccountSpecificPrefKey(accountName, PREFIX_PREF_PLUS_IMAGE_URL), imageUrl).apply(); }
From source file:Main.java
public static Boolean putFloat(String preName, Context context, String key, float value) { SharedPreferences pre = context.getSharedPreferences(preName, Context.MODE_PRIVATE); Editor editor = pre.edit(); editor.putFloat(key, value);//from www . j a v a2s . c om return editor.commit(); }
From source file:Main.java
public static Boolean putString(String preName, Context context, String key, String value) { SharedPreferences pre = context.getSharedPreferences(preName, Context.MODE_PRIVATE); Editor editor = pre.edit(); editor.putString(key, value);//from w w w . j a va 2s. c o m return editor.commit(); }
From source file:Main.java
public static Boolean putInt(String preName, Context context, String key, int value) { SharedPreferences pre = context.getSharedPreferences(preName, Context.MODE_PRIVATE); Editor editor = pre.edit(); editor.putInt(key, value);/*from www. j a v a2 s . c o m*/ return editor.commit(); }
From source file:Main.java
/** * Delete a preference.//from w ww. j a v a 2 s.c o m * * @param ctxt * The current context. * @param pref * The name of the preference */ public static void delPref(Context ctxt, String pref) { SharedPreferences sharedPreferences = ctxt.getSharedPreferences("drupoid", Context.MODE_PRIVATE); sharedPreferences.edit().remove(pref).apply(); }
From source file:Main.java
public static void setPlusName(final Context context, final String accountName, final String name) { SharedPreferences sp = getSharedPreferences(context); sp.edit().putString(makeAccountSpecificPrefKey(accountName, PREFIX_PREF_PLUS_NAME), name).apply(); }
From source file:Main.java
public static void saveMac(Context context, String mac) { SharedPreferences sharedPreferences = context.getSharedPreferences(MAC_ADDRESS, Context.MODE_PRIVATE); sharedPreferences.edit().putString(MAC_ADDRESS, mac).commit(); }