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 String getString(Context context, String key, String defaultValue) { SharedPreferences sp = context.getSharedPreferences(NAME, Context.MODE_PRIVATE); return sp.getString(key, defaultValue); } }