Java tutorial
//package com.java2s; import android.content.Context; import android.content.SharedPreferences; public class Main { private static final String SHARED_NAME = "SharedPreferences"; public static String getString(Context context, String key, String defValue) { SharedPreferences sp = getSharedPreferences(context); return sp.getString(key, defValue); } private static SharedPreferences getSharedPreferences(Context context) { return context.getSharedPreferences(SHARED_NAME, Context.MODE_PRIVATE); } }