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 void setUserName(final Context context, final String name) {
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    sp.edit().putString(PREF_NAME, name).commit();
}

From source file:Main.java

public static void setChatBg(Context context, String key, String url) {
    SharedPreferences spf = context.getSharedPreferences("chat", Context.MODE_PRIVATE);
    spf.edit().putString(key, url).commit();
}

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

public static void setBoolean(Context ctx, String key, boolean value) {
    SharedPreferences spf = ctx.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
    spf.edit().putBoolean(key, value).apply();
}

From source file:Main.java

public static void setUrl(Context context, String url) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    prefs.edit().putString(PREFERENCE_DSU_URL, url).commit();
}

From source file:Main.java

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

}

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

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