我使用共享首选项来存储密码,但是当我的应用程序启动时再次询问首选项值。我希望一旦我输入了首选项密码就应该修复它应该一次又一次地问我。
答案 0 :(得分:8)
您想要保存密码的位置,请使用以下代码 -
Editor editor = getSharedPreferences("password", 0).edit();
editor.putString("password", "your password");
editor.commit();
在那里你想把它放回到代码下面 -
SharedPreferences pref = getSharedPreferences("password", 1);
String password = pref.getString("password", "");
如果仍然无效,请将您的代码放在此处。