Android的共享preferences找回用户名和密码 [英] Android shared preferences retrieve username and password
本文介绍了Android的共享preferences找回用户名和密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
林其与Android的共享preferences获取用户名和密码的麻烦。我用这个code保存的用户名,并通过
Im having trouble with retrieving username and password from android's sharedpreferences. I use this code to save the username and pass
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");
但我不知道如何获取信息的用户进行登录。任何人都可以帮我找出
But i dont know how to retrieve information for user to log in. Can anybody help me figure out
推荐答案
创建共享preference:
SharedPreferences sp=getSharedPreferences("Login", 0);
SharedPreferences.Editor Ed=sp.edit();
Ed.putString("Unm",Value );
Ed.putString("Psw",Value);
Ed.commit();
从分享preference获得值:
SharedPreferences sp1=this.getSharedPreferences("Login",null);
String unm=sp1.getString("Unm", null);
String pass = sp1.getString("Psw", null);
这篇关于Android的共享preferences找回用户名和密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文