1

2 人のユーザーが同じセッションでログインおよびログアウトできるように、設定を共有するマルチセッションを作成するにはどうすればよいですか?

次のコードがあります。

public class Session 
{
    SharedPreferences prefs;
    SharedPreferences.Editor editor;
    Context ctx;
    String [][] usuarios;
    int i,j;

    public Session(Context ctx)
    {
        this.ctx = ctx;
        prefs = ctx.getSharedPreferences("init", Context.MODE_PRIVATE);
        editor = prefs.edit();
    }

    public void setLoggedIn(boolean loggedin)
    {
        editor.putBoolean("loggedinmode",loggedin);
        editor.commit();
    }

    public boolean loggedin()
    {
        return prefs.getBoolean("loggedinmode",false);
    }
}

Androidスタジオを使用しています。

4

2 に答える 2