码迷,mamicode.com
首页 > 移动开发 > 详细

Android - 使用SharedPreference判断字符串是否修改

时间:2014-12-09 09:23:54      阅读:208      评论:0      收藏:0      [点我收藏+]

标签:mystra   android   string   sharedpreference   字符串未发生改变   

使用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昵称未发生改变。

Android - 使用SharedPreference判断字符串是否修改

标签:mystra   android   string   sharedpreference   字符串未发生改变   

原文地址:http://blog.csdn.net/caroline_wendy/article/details/41819389

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!