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 saveUseGateway(SharedPreferences settings, boolean value) {
    SharedPreferences.Editor editor = settings.edit();
    editor.putBoolean("clientusegateway", value);
    editor.commit();/*  w w  w . j av  a 2  s. c o m*/
}

From source file:Main.java

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

From source file:Main.java

public static void putBooleanToDefault(Context context, String key, boolean value) {
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    sp.edit().putBoolean(key, value).commit();
}

From source file:Main.java

public static void putStringToDefault(Context context, String key, String value) {
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    sp.edit().putString(key, value).commit();
}

From source file:Main.java

public static void saveGlobalSetting(Context ctx, String name, Object value) {
    SharedPreferences setting = ctx.getSharedPreferences(ctx.getPackageName(), 0);
    setting.edit().putString(name, value.toString()).commit();
}

From source file:Main.java

public static void remove(String key, Context ctx) {
    SharedPreferences sp = ctx.getSharedPreferences("config", Context.MODE_PRIVATE);
    sp.edit().remove(key).commit();
}

From source file:Main.java

private static final SharedPreferences.Editor getEditor(Context context) {
    SharedPreferences sharedPreferences = getSharedPreference(context);
    return sharedPreferences.edit();
}

From source file:Main.java

public static void setPlusNameImageURL(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 void setString(Context ctx, String key, String value) {
    SharedPreferences sp = ctx.getSharedPreferences("config", Context.MODE_PRIVATE);
    sp.edit().putString(key, value).commit();
}

From source file:Main.java

public static boolean clearUserInfo(Context context) {
    SharedPreferences sp = context.getSharedPreferences("saveSelfInfo", 0);
    return sp.edit().clear().commit();
}