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 markDataBootstrapDone(final Context context) {
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    sp.edit().putBoolean(PREF_DATA_BOOTSTRAP_DONE, true).commit();
}

From source file:Main.java

public static void putPlaymode(Context context, String key, int value) {
    SharedPreferences sharedPreferences = context.getSharedPreferences("fucang", Context.MODE_PRIVATE);
    sharedPreferences.edit().putInt(key, value).commit();
}

From source file:Main.java

public static void clearAlarmRecord(Context context) {
    SharedPreferences sh = context.getSharedPreferences("alarm_record", Activity.MODE_PRIVATE);
    sh.edit().clear().commit();
}

From source file:Main.java

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

From source file:Main.java

public static void setLoggedIn(final Context context, boolean isLoggedIn) {
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    sp.edit().putBoolean(PREF_LOGGED_IN, isLoggedIn).commit();
}

From source file:Main.java

public static void putCount(Context context, int count) {
    SharedPreferences preferences = context.getSharedPreferences(DOWN_COUNT, Context.MODE_PRIVATE);
    preferences.edit().putInt(DOWN_COUNT_KEY, count).commit();
}

From source file:Main.java

public static void putPlaymode(Context context, String key, int values) {
    SharedPreferences sharedPreferences = context.getSharedPreferences("atqiye", Context.MODE_PRIVATE);
    sharedPreferences.edit().putInt(key, values).commit();
}

From source file:Main.java

public static void saveSp(Context ctx, String spName, String key, String value) {
    SharedPreferences sp = ctx.getSharedPreferences(spName, Context.MODE_PRIVATE);
    Editor editor = sp.edit();
    editor.putString(key, value);/*from w  w  w.ja  v  a  2 s .  c o  m*/
    editor.commit();
}

From source file:Main.java

public static boolean saveArray(SharedPreferences prefs, String[] array, String arrayName) {
    SharedPreferences.Editor editor = prefs.edit();
    editor.putInt(arrayName + "_size", array.length);
    for (int i = 0; i < array.length; i++)
        editor.putString(arrayName + "_" + i, array[i]);
    return editor.commit();
}

From source file:Main.java

public static void setUsingLocalTime(final Context context, final boolean usingLocalTime) {
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    sp.edit().putBoolean(PREF_LOCAL_TIMES, usingLocalTime).commit();
}