如何创建具有共享首选项的多会话,以便两个用户可以在同一个会话中登录和注销?
我有以下代码。
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);
}
}
我正在使用安卓工作室。