Java tutorial
//package com.java2s; import android.content.Context; import android.content.SharedPreferences; import android.preference.PreferenceManager; public class Main { public static Boolean getPreferences(Context context, String key, boolean defValue) { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); Boolean savedPref = sharedPreferences.getBoolean(key, defValue); return savedPref; } public static String getPreferences(Context context, String key, String defValue) { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); String savedPref = sharedPreferences.getString(key, defValue); return savedPref; } public static Integer getPreferences(Context context, String key, int defValue) { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); Integer savedPref = sharedPreferences.getInt(key, defValue); return savedPref; } }