这是我的json
Feed
我需要以共享的偏好存储电子邮件和密码,并且需要检查用户输入的内容..如果它是正确的我应该显示一个消息..其他我应该注册
答案 0 :(得分:3)
解析JSON
JSONObject objMain = new JSONObject("String");
JSONObject memberDetail = objMain.optJSONObject("member_details");
String unm = memberDetail.optString("username");
String pwd = memberDetail.optString("password");
将其存储到SharedPreferences
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
Editor ed = sp.edit();
ed.putString("unm", unm);
ed.putString("pwd", pwd);
ed.commit();
从SharedPreferences读取
SharedPreferences sp1 = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
String unmStored = sp1.getString("unm","");
String pwdStored = sp1.getString("pwd","");