Android共享首选项检索用户名和密码

Wor*_*123 2 authentication android login sharedpreferences

我无法从android的共享偏好中检索用户名和密码.我使用此代码保存用户名并传递

SharedPreferences prefs=getSharedPreferences("File", 0);
    SharedPreferences.Editor e=  prefs.edit();
       e.putString("Email", "example@example.com").putString("Password", "password1");
       e.commit();
       e.putString("Email", "example_2@example.com").putString("Password", "password2");
       e.commit();
       String s=prefs.getString("Email","not found");
Run Code Online (Sandbox Code Playgroud)

但我不知道如何检索用户登录的信息.任何人都可以帮我解决

Has*_*ukh 5

创建共享首选项:

SharedPreferences sp=getSharedPreferences("Login", 0);
SharedPreferences.Editor Ed=sp.edit();
Ed.putString("Unm",Value );              
Ed.putString("Psw",Value);   
Ed.commit();
Run Code Online (Sandbox Code Playgroud)

从共享偏好中获取价值:

SharedPreferences sp1=this.getSharedPreferences("Login",null);

String unm=sp1.getString("Unm", null);       
String pass = sp1.getString("Psw", null);
Run Code Online (Sandbox Code Playgroud)