Java tutorial
//package com.java2s; import android.content.Context; import android.content.SharedPreferences; public class Main { private static final String PREF_NAME = "mypref"; /** * save int value to preference memory */ public static void saveInt(Context context, String key, int value) { if (context == null) return; SharedPreferences pref = context.getSharedPreferences(PREF_NAME, 0); SharedPreferences.Editor editor = pref.edit(); editor.putInt(key, value); editor.commit(); } }