Java tutorial
//package com.java2s; //License from project: Open Source License import android.content.Context; import android.content.SharedPreferences; public class Main { private static final String NAME = "config"; /** * Get value by key in config * @param context context * @param key the key * @param defaultValue if can't find the value of key, will return default value * @return value */ public static int getInt(Context context, String key, int defaultValue) { SharedPreferences sp = context.getSharedPreferences(NAME, Context.MODE_PRIVATE); return sp.getInt(key, defaultValue); } }