Example usage for android.content SharedPreferences edit

List of usage examples for android.content SharedPreferences edit

Introduction

In this page you can find the example usage for android.content SharedPreferences edit.

Prototype

Editor edit();

Source Link

Document

Create a new Editor for these preferences, through which you can make modifications to the data in the preferences and atomically commit those changes back to the SharedPreferences object.

Usage

From source file:Main.java

public static boolean saveAddressLibUpdateTime(Context context, String updateTime) {
    SharedPreferences prefs = getSharedPreference(context);
    Editor editor = prefs.edit();
    editor.putString(ADDRESS_LIB_UPDATE_TIME, updateTime);
    return editor.commit();
}

From source file:Main.java

public static void putString(Context context, String key, String value) {
    SharedPreferences sp = context.getSharedPreferences("superlol", Context.MODE_PRIVATE);
    sp.edit().putString(key, value).commit();

}

From source file:Main.java

public static void putBoolean(Context context, String key, boolean value) {
    SharedPreferences sp = context.getSharedPreferences("atguigu", Context.MODE_PRIVATE);
    sp.edit().putBoolean(key, value).commit();
}

From source file:Main.java

public static void putPlaymode(Context context, String key, int value) {
    SharedPreferences sp = context.getSharedPreferences("atguigu", Context.MODE_PRIVATE);
    sp.edit().putInt(key, value).commit();

}

From source file:Main.java

public static void setChosenAccountName(final Context context, final String accountName) {
    Log.d(TAG, "Chose account " + accountName);
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    sp.edit().putString(PREF_CHOSEN_ACCOUNT, accountName).commit();
}

From source file:Main.java

public static void putBoolean(Context mContext, String key, boolean values) {
    SharedPreferences sp = mContext.getSharedPreferences(SHARE_NAME, Context.MODE_PRIVATE);
    sp.edit().putBoolean(key, values).commit();
}

From source file:Main.java

public static void saveStringSp(Context context, String key, String value) {
    SharedPreferences sp = context.getSharedPreferences(CONFIG_NAME, context.MODE_PRIVATE);
    sp.edit().putString(key, value).commit();
}

From source file:Main.java

public static void putInt(Context mContext, String key, int values) {
    SharedPreferences sp = mContext.getSharedPreferences(SHARE_NAME, Context.MODE_PRIVATE);
    sp.edit().putInt(key, values).commit();
}

From source file:Main.java

public static void saveCache(Context context, String key, String result) {
    SharedPreferences sp = context.getSharedPreferences("cacheUtils", Context.MODE_PRIVATE);
    sp.edit().putString(key, result).apply();
}

From source file:Main.java

public static void setStrValue(Context context, String name, String value) {
    SharedPreferences pref = getPref(context, DEF_PREF_NAME);
    Editor editor = pref.edit();
    editor.putString(name, value);/*from  www  .ja  v a2  s  .  co m*/
    editor.commit();
}