SharedPreferences sp = this.getSharedPreferences(SP_NAME, 0); SharedPreferences.Editor editor = sp.edit(); // ① editor.putString(SP_KEY_USERNAME, editUsername.getText().toString()); editor.putString(SP_KEY_PASSWORD, editPassword.getText().toString()); editor.putString(SP_KEY_IS_REMEMBER, SP_VAL_REMEMBER_OK); editor.commnt() // ② 需要注意的一点是 editor 必须 commit 否则保存失败 第二点 我犯了一个很xx的错误(不知道xx用啥来形容) sp.edit().putString(SP_KEY_USERNAME, editUsername.getText().toString()); sp.edit().putString(SP_KEY_PASSWORD, editPassword.getText().toString()); sp.edit().putString(SP_KEY_IS_REMEMBER, SP_VAL_REMEMBER_OK);