我是 Android 的新手。我的要求是通过在 android 中使用 sharedpreferences 为登录屏幕实现简单的身份验证逻辑。 谁能建议我...?
最佳答案
在用户注册后(创建用户时)保存详细信息...
// Get the app's shared preferences
SharedPreferences login_app_preferences = context.getSharedPreferences("LOGIN_DETAILS", MODE_PRIVATE);
// Update fields
SharedPreferences.Editor editor = login_app_preferences.edit();
editor.putString("email", strEmailOrLoginId);
editor.putString("password", strPassword);
editor.commit(); // Very important
在应用程序的任何地方访问它....
// Get the app's shared preferences
SharedPreferences login_app_preferences = context.getSharedPreferences("LOGIN_DETAILS", MODE_PRIVATE);
strUserName = login_app_preferences.getString("email", "");
strPassword = login_app_preferences.getString("password", "");
关于android - 如何在android中使用共享首选项实现身份验证?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5933199/