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", "")); }
最後更新:2017-04-03 12:54:29