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