SharedPreferences





  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", ""));
	  }











原文地址:https://www.cnblogs.com/flyingsir/p/3983720.html