SharedPreferences
原创
©著作权归作者所有:来自51CTO博客作者qq62d9de275644f的原创作品,请联系作者获取转载授权,否则将追究法律责任
private void saveAccount(String username, String password) {
SharedPreferences sp = this.getPreferences(this.MODE_PRIVATE); // 获得Preferences
SharedPreferences.Editor editor = sp.edit(); // 获得Editor
editor.putString("username", username); // 将用户名存入Preferences
editor.putString("password", password); // 将密码存入Preferences
editor.commit();
}
private Map<String, String> getAccount(){
SharedPreferences sp = this.getPreferences(this.MODE_PRIVATE);
Map<String, String> m = new Map<String, String>();
m.put("username", sp.getString("username", ""));
m.put("password", sp.getString("password", ""));
}