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 SpIntertInt(Context c, String key, int value) {
    SharedPreferences sp = c.getSharedPreferences("XGram", Context.MODE_WORLD_READABLE);
    SharedPreferences.Editor editor = sp.edit();
    editor.putInt(key, value);/*w  w  w .ja va2s. co m*/
    editor.apply();
}

From source file:Main.java

static public void removePreferences(Context context, String key) {
    SharedPreferences pref = context.getSharedPreferences("pref", Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = pref.edit();
    editor.remove(key);/*from w w  w. j ava2  s.  c  o  m*/
    editor.commit();
}

From source file:Main.java

public static void saveString(Context context, String key, String value) {
    SharedPreferences sp = context.getSharedPreferences("myshop", Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = sp.edit();
    editor.putString(key, value);/*from  ww  w.  j  av a 2 s . c o m*/
    editor.commit();
}

From source file:Main.java

static public void saveStringPreferences(Context context, String key, String value) {
    SharedPreferences pref = context.getSharedPreferences("pref", Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = pref.edit();
    editor.putString(key, value);/*from   w  w  w .j  a  va 2  s .  co  m*/
    editor.commit();
}

From source file:Main.java

static public void saveIntegerPreferences(Context context, String key, int value) {
    SharedPreferences pref = context.getSharedPreferences("pref", Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = pref.edit();
    editor.putInt(key, value);//w ww .  j a  v  a 2 s. c o  m
    editor.commit();
}

From source file:Main.java

public static void setDefaults(String key, String value, Context context) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    SharedPreferences.Editor editor = prefs.edit();
    editor.putString(key, value);//from   www  .ja v  a2s . c  o m
    editor.commit();
}

From source file:Main.java

/**
 * @Title: saveSettingRingtone//w  w w. j a v  a  2  s .com
 * @Description: Save current setting ring tone
 * @param context
 * @param type
 * @param id
 * @return void
 * @throws
 */
public static void saveSettingRingtone(Context context, int type, String id) {
    SharedPreferences mSharePref = PreferenceManager.getDefaultSharedPreferences(context);
    Editor mEditor = mSharePref.edit();
    mEditor.putString(TYPE_PRE + type, id);
    mEditor.commit();
}

From source file:Main.java

public static void storeLoginStatus(Context context, String loginStatus) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    SharedPreferences.Editor editor = prefs.edit();
    editor.putString(LOGIN, loginStatus);
    editor.apply();//w w w. j  ava2  s.c o  m
}

From source file:Main.java

public static void storeAdmin(Context context, String isAdmin) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    SharedPreferences.Editor editor = prefs.edit();
    editor.putString(ADMIN, isAdmin);//  w w  w  . ja  va2  s.c  o  m
    editor.apply();
}

From source file:Main.java

public static void storePinCode(Context context, String code) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    SharedPreferences.Editor editor = prefs.edit();
    editor.putString(PINCODE, code);//from w ww .  ja  v a  2s .  co  m
    editor.apply();
}