Java tutorial
//package com.java2s; import android.content.Context; import android.content.SharedPreferences; import android.preference.PreferenceManager; public class Main { public static void setInt(Context context, final String key, final int value) { final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context); settings.edit().putInt(key, value).commit(); } }