Java tutorial
//package com.java2s; import android.content.Context; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; public class Main { public static final String DEF_PREF_NAME = "Default"; public static void setIntValue(Context context, String name, int value) { SharedPreferences pref = getPref(context, DEF_PREF_NAME); Editor editor = pref.edit(); editor.putInt(name, value); editor.commit(); } public static SharedPreferences getPref(Context context, String name) { return context.getSharedPreferences(name, Context.MODE_PRIVATE); } }