Java tutorial
//package com.java2s; //License from project: Open Source License import android.content.Context; import android.content.SharedPreferences; import android.preference.PreferenceManager; import android.support.annotation.Nullable; public class Main { @Nullable private static String getString(Context context, String key) { SharedPreferences sp = getSharedPreferences(context); return sp.getString(key, null); } private static SharedPreferences getSharedPreferences(final Context context) { return PreferenceManager.getDefaultSharedPreferences(context); } }