Java tutorial
//package com.java2s; import android.content.Context; import android.preference.PreferenceManager; import java.util.HashSet; public class Main { public static final String LOGGED_IN_USER_PREFERENCE_KEY = "logged_in_user"; public static boolean isUserLoggedIn(Context context) { return !PreferenceManager.getDefaultSharedPreferences(context) .getStringSet(LOGGED_IN_USER_PREFERENCE_KEY, new HashSet<String>()).isEmpty(); } }