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 setFirstStart(Context context, boolean isFirstStart) {

    SharedPreferences exam_info = context.getSharedPreferences("exam", 0);
    exam_info.edit().putBoolean("is_first", isFirstStart).commit();
}

From source file:Main.java

public static void saveData(SharedPreferences sp, Map<String, String> datas) {
    Editor editor = sp.edit();
    for (Map.Entry<String, String> entry : datas.entrySet()) {
        editor.putString(entry.getKey(), entry.getValue());
    }//from  ww w. j a  va  2  s.  co m
    editor.commit();
}

From source file:Main.java

public static void saveMaxSpeedSeekbar(SharedPreferences settings, int value) {
    SharedPreferences.Editor editor = settings.edit();
    editor.putInt("clientmaxseekbar", value);
    editor.commit();//from   ww w.j a v  a2 s .  c o  m
}

From source file:Main.java

public static void cleanPrefs(SharedPreferences sharedPrefs) {
    SharedPreferences.Editor editor = sharedPrefs.edit();
    for (String key : prefsClean) {
        editor.remove(key);/*  w ww. j  a  v  a2 s  .co  m*/
    }
    editor.apply();
}

From source file:Main.java

public static void adicionarValores(Context context, String chave, String valor) {
    SharedPreferences settings = context.getSharedPreferences(PREFERENCES, 0);
    settings.edit().putString(chave, valor).commit();
}

From source file:Main.java

public static void saveColor(Context context, int color) {
    SharedPreferences settings = context.getSharedPreferences(PREFERENCES, 0);
    settings.edit().putInt(COLOR, color).commit();
}

From source file:Main.java

public static void setCacheData(Context context, String data) {
    SharedPreferences settings = context.getSharedPreferences("Preference", 0);
    settings.edit().putString("CacheData", data).commit();
}

From source file:Main.java

public static void setCacheTime(Context context, long time) {
    SharedPreferences settings = context.getSharedPreferences("Preference", 0);
    settings.edit().putLong("CacheTime", time).commit();
}

From source file:Main.java

public static void setSkin(SharedPreferences sp, String skinCode) {
    SharedPreferences.Editor editor = sp.edit();
    editor.putString("skindata", skinCode);
    editor.commit();/*w  ww .j a va2 s .  c  o m*/
}

From source file:Main.java

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