使用SharedPreference判断字符串是否修改
本文地址: http://blog.csdn.net/caroline_wendy
判断字符串是否修改,可以把字符串存储在SharedPreference内,判断两次是否相同;
private void modifyName(final String name) { EmptyWebOperationCallback callback = new EmptyWebOperationCallback(this) { @Override public void operationExecutedSuccess(WebOperation operation, WebOperation.WebOperationRequestResult data) { String modifiedName = PreferenceUtils.get(getApplicationContext(), PREF_MODIFIED_NAME, ""); Log.d(DEBUG_WCL+TAG, "name = " + modifiedName); if (name.equals(modifiedName)) { showToast("昵称未发生改变"); } nameView.setText(name); PreferenceUtils.setPreference(getApplicationContext(), PREF_MODIFIED_NAME, nameView.getText().toString()); User.getUser(MyTaskActivity.this).setDisplayName(name); } }; ModUserInfoOperation operation = new ModUserInfoOperation(name, null, callback); getScheduler().sendBlockOperation(this, operation, getString(R.string.mytask_modifying_name)); }
内容相同时,则提示Toast昵称未发生改变。
时间: 2024-10-13 05:02:25