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 deleteSettingValue(Context context, String path, String key) {
    SharedPreferences settingInfo = context.getSharedPreferences(path, 0);
    Editor editor = settingInfo.edit();
    editor.remove(key);/*from   w w  w. j a  va  2 s .com*/
    editor.commit();
}

From source file:Main.java

public static void setAccountId(final Context context, final String accountName, final String id) {
    SharedPreferences sp = getSharedPreferences(context);
    sp.edit().putString(makeAccountSpecificPrefKey(accountName, PREFIX_PREF_ID), id).commit();
}

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).commit();
}

From source file:Main.java

public static void setAvatarMini(final Context context, final String accountName, final String imageUrl) {
    SharedPreferences sp = getSharedPreferences(context);
    sp.edit().putString(makeAccountSpecificPrefKey(accountName, PREFIX_PREF_AVATAR_MINI), imageUrl).commit();
}

From source file:Main.java

public static void setAvatarNormal(final Context context, final String accountName, final String imageUrl) {
    SharedPreferences sp = getSharedPreferences(context);
    sp.edit().putString(makeAccountSpecificPrefKey(accountName, PREFIX_PREF_AVATAR_NORMAL), imageUrl).commit();
}

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).commit();
}

From source file:Main.java

public static void setAvatarLarge(final Context context, final String accountName, final String imageUrl) {
    SharedPreferences sp = getSharedPreferences(context);
    sp.edit().putString(makeAccountSpecificPrefKey(accountName, PREFIX_PREF_AVATAR_LARGE), imageUrl).commit();
}

From source file:Main.java

public static void editDeviceId(Context context, String deviceId) {
    SharedPreferences preferences = context.getSharedPreferences(DEVICE, Context.MODE_PRIVATE);
    preferences.edit().putString(DEVICEID, deviceId).commit();
}

From source file:Main.java

public static void deleteIp(Context context) {
    SharedPreferences preferences = context.getSharedPreferences(IP_PORT, Context.MODE_PRIVATE);
    preferences.edit().clear().commit();
}

From source file:Main.java

public static void setUseCelsius(Context context, boolean use_celsius) {
    SharedPreferences pref = context.getSharedPreferences(SETTINGS_PREF, Context.MODE_PRIVATE);
    pref.edit().putBoolean(PREF_USE_CELSIUS, use_celsius).commit();
}