Java tutorial
//package com.java2s; //License from project: Open Source License import android.content.Context; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; import android.preference.PreferenceManager; public class Main { public static void setBind(Context context, boolean flag) { setBind(context, "push_flag", flag); } public static void setBind(Context context, String bindStr, boolean flag) { String flagStr = "not"; if (flag) { flagStr = "ok"; } setBindStr(context, bindStr, flagStr); } public static void setBindStr(Context context, String bindStr, String strValue) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); Editor editor = sp.edit(); editor.putString(bindStr, strValue); editor.commit(); } }