Java tutorial
//package com.java2s; import android.content.Context; import android.content.SharedPreferences; import android.preference.PreferenceManager; public class Main { public static int getPrefInt(Context context, final String key, final int defaultValue) { final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context); return settings.getInt(key, defaultValue); } }