Java tutorial
//package com.java2s; //License from project: Apache License import android.content.Context; import android.content.SharedPreferences; import android.preference.PreferenceManager; import android.text.TextUtils; public class Main { private static final String VivaLastSentence = "VivaLastSentence"; public static boolean isVivaLastSentenceSame(Context context, String vivaLastSentence) { String lastSentence = getVivaLastSentence(context); if (!TextUtils.isEmpty(lastSentence)) { if (vivaLastSentence.equalsIgnoreCase(lastSentence)) { return true; } else { return false; } } else { return false; } } public static String getVivaLastSentence(Context context) { return getPreferences(context).getString(VivaLastSentence, null); } /** * Default Preference Helper * @param context - the calling application context. * @return Shared Preferences */ private static SharedPreferences getPreferences(Context context) { return PreferenceManager.getDefaultSharedPreferences(context); } }