Java tutorial
//package com.java2s; import android.content.Context; import android.content.SharedPreferences; public class Main { public static final String PREFERENCE_NAME = "settings_share"; /** * put boolean preferences * * @param context * @param key The name of the preference to modify * @param value The new value for the preference * @return True if the new values were successfully written to persistent storage. */ public static boolean putBoolean(Context context, String key, boolean value) { SharedPreferences settings = getDefaultPreferences(context); SharedPreferences.Editor editor = settings.edit(); editor.putBoolean(key, value); return editor.commit(); } private static SharedPreferences getDefaultPreferences(Context context) { return context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE); } }