Java tutorial
//package com.java2s; import android.content.Context; import android.content.SharedPreferences; public class Main { private static final String PREFERENCE_NAME = "update_state"; public static void setPreference(Context context, String key, String value) { SharedPreferences.Editor prefsEditor = context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE) .edit(); prefsEditor.putString(key, value); prefsEditor.commit(); } public static void setPreference(Context context, String key, boolean value) { SharedPreferences.Editor prefsEditor = context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE) .edit(); prefsEditor.putBoolean(key, value); prefsEditor.commit(); } public static void setPreference(String preference, Context context, String key, boolean value) { SharedPreferences.Editor prefsEditor = context.getSharedPreferences(preference, Context.MODE_PRIVATE) .edit(); prefsEditor.putBoolean(key, value); prefsEditor.commit(); } }