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

private static void setChosenAccountName(final Context context, final String accountName) {
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    sp.edit().putString(PREF_CHOSEN_ACCOUNT, accountName).commit();
}

From source file:Main.java

public static void setPlusProfileId(final Context context, final String profileId) {
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    sp.edit().putString(PREF_PLUS_PROFILE_ID, profileId).commit();
}

From source file:Main.java

public static void removeKey(Context context, String key) {
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    sp.edit().remove(key).apply();
}

From source file:Main.java

public static void putIntPreference(Context context, String key, int value) {
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    sp.edit().putInt(key, value).apply();
}

From source file:Main.java

public static void putLiveType(Context context, String type) {
    SharedPreferences preferences = context.getSharedPreferences(LIVE_TYPE, Context.MODE_PRIVATE);
    preferences.edit().putString(CVALUE, type).commit();
}

From source file:Main.java

public static void setDeskEffect(Context context, int tap) {
    SharedPreferences preferences = context.getSharedPreferences("DeskEffect", Context.MODE_PRIVATE);
    preferences.edit().putInt("DeskEffectItem", tap).commit();
}

From source file:Main.java

public static void storeDevieId(String deviceId, Context context) {
    SharedPreferences mPrefs = context.getSharedPreferences(DEVICE_ID_FILE, Context.MODE_PRIVATE);
    mPrefs.edit().putString(deviceId, DEVICE_ID_KEY).commit();
}

From source file:Main.java

public static void markDebugWarningShown(final Context context) {
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    sp.edit().putBoolean(PREF_DEBUG_BUILD_WARNING_SHOWN, true).commit();
}

From source file:Main.java

public static void putUserName(Context context, String content) {
    SharedPreferences preferences = context.getSharedPreferences(DOWN_COUNT, Context.MODE_PRIVATE);
    preferences.edit().putString(USER_NAME, content).commit();
}

From source file:Main.java

public static void putBooleanShareData(String key, boolean value) {
    SharedPreferences sp = mContext.getSharedPreferences(KEY, Context.MODE_PRIVATE);
    Editor et = sp.edit();
    et.putBoolean(key, value);//ww w . ja v a  2  s. c o  m
    et.commit();
}