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 setSex(Context context, String sex) {
    SharedPreferences sp = getSP(context);
    SharedPreferences.Editor editor = sp.edit();
    editor.putString("sex", sex);
    editor.apply();// w  ww.  j ava  2s  . c  o m
}

From source file:Main.java

public static void setLongitude(Context context, String longitude) {
    SharedPreferences sp = getSP(context);
    SharedPreferences.Editor editor = sp.edit();
    editor.putString("longitude", longitude);
    editor.apply();/*w w w .  ja  va  2  s .  c  o m*/
}

From source file:Main.java

public static void setPlusCoverURL(Context context, final String accountName, String coverPhotoUrl) {
    SharedPreferences sp = getSharedPreferences(context);
    sp.edit().putString(makeAccountSpecificPrefKey(accountName, PREFIX_PREF_PLUG_COVER_URL), coverPhotoUrl)
            .apply();/*from   www.  ja v  a  2  s  . co  m*/
}

From source file:Main.java

private static SharedPreferences.Editor getEditor(Context context) {
    SharedPreferences preferences = getSharedPreferences(context);
    return preferences.edit();
}

From source file:Main.java

public static void saveRefreshTime(Context context, long currentTimeMillis, String string) {
    SharedPreferences dePreferences = context.getSharedPreferences("refresh_time", 0);
    dePreferences.edit().putLong(string, currentTimeMillis).commit();
}

From source file:Main.java

public static void setPhone(Context context, String phone) {
    SharedPreferences sp = getSP(context);
    SharedPreferences.Editor editor = sp.edit();
    editor.putString("phone", phone);
    editor.apply();//from   w  w w .ja va2  s. c  om
}

From source file:Main.java

public static void putLong(Context context, String key, long value) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    prefs.edit().putLong(key, value).apply();
}

From source file:Main.java

public static void setUserEmail(final Context context, final String email) {
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    sp.edit().putString(PREF_EMAIL, email).commit();
}

From source file:Main.java

public static void setFullName(final Context context, final String fullName) {
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    sp.edit().putString(PREF_FULLNAME, fullName).apply();
}

From source file:Main.java

public static void setUserEmail(final Context context, final String email) {
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    sp.edit().putString(PREF_EMAIL, email).apply();
}