Java tutorial
//package com.java2s; import android.content.Context; import android.content.SharedPreferences; import android.preference.PreferenceManager; import java.util.HashSet; import java.util.Set; public class Main { public static final String LOGGED_IN_USER_PREFERENCE_KEY = "logged_in_user"; public static void logOutUser(Context context, String userId) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); Set<String> currentUsers = prefs.getStringSet(LOGGED_IN_USER_PREFERENCE_KEY, new HashSet<>()); currentUsers.remove(userId); PreferenceManager.getDefaultSharedPreferences(context).edit() .putStringSet(LOGGED_IN_USER_PREFERENCE_KEY, currentUsers).commit(); } }