林其与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如何停止数据库插入过程过程、数据库、Andr、oid
下一篇:windowBackground Android中6(棉花糖)棉花、windowBackground、Android