Java tutorial
//package com.java2s; import android.content.SharedPreferences; import android.text.TextUtils; public class Main { public static SharedPreferences sp; public static boolean checkUserToken() { checkSP(); String token = sp.getString("matrix_user_token", ""); if (TextUtils.isEmpty(token)) { return false; } else { return true; } } public static void checkSP() { if (sp == null) { // initSP(MatrixApplication.mContext); } } public static String getString(String key, String defValue) { checkSP(); return sp.getString(key, defValue); } }