(详细代码,文末Demo下载)android简单修改密码、登录、注册功能 基于android 4.x...

修改密码主要代码:db.execSQL("update user set passward = ? where username = ?",new String[] { updata_newpass, updata_user });

 

 

修改密码功能全部代码:
// 修改密码确定

        updata_newpass = et_updata_newpass.getText().toString();// 新密码
        updata_oldpass = et_updata_oldpass.getText().toString();// 新密码
        updata_user = et_updata_user.getText().toString();// 新密码
        Cursor cursor_getuser = db.rawQuery(
                "select * from user where username = ?",
                new String[] { updata_user });// 新建数据库指针
        if (updata_user.equals("")) {// 用户名为空
            DiyToast.showToast(LoginActivity.this, "请输入用户名");
        } else if (updata_oldpass.equals("")) {// 旧密码为空
            DiyToast.showToast(LoginActivity.this, "请输入旧密码");
        } else if (updata_newpass.equals("")) {// 新密码为空
            DiyToast.showToast(LoginActivity.this, "请输入新密码");
        } else {
            if (cursor_getuser.moveToNext()) {
                Cursor cursor_getoldpass = db.rawQuery(
                        "select * from user where username = ?",
                        new String[] { updata_user });
                cursor_getoldpass.moveToFirst();
                String oldpass = cursor_getoldpass
                        .getString(cursor_getoldpass
                                .getColumnIndex("passward"));
                if (updata_oldpass.equals(oldpass)) {
                    if (updata_newpass.equals(updata_oldpass)) {
                        DiyToast.showToast(LoginActivity.this, "新旧密码不能一致!");
                    } else {
                        db.execSQL(
                                "update user set passward = ? where username = ?",
                                new String[] { updata_newpass, updata_user });// 更新数据库
                        DiyToast.showToast(LoginActivity.this, "修改密码成功");
                        line_login.setVisibility(View.VISIBLE);
                        line_reg.setVisibility(View.GONE);
                        line_updata_pass.setVisibility(View.GONE);
                    }
                } else {
                    DiyToast.showToast(LoginActivity.this, "旧密码输入错误");
                }
            } else {
                DiyToast.showToast(LoginActivity.this, "用户名错误");
            }
        }

Demo下载:
链接: https://pan.baidu.com/s/1wAFak_YMI8CzhMCKrMm0Yg 提取码: 1riq

 

 

 

转载于:https://my.oschina.net/u/4191659/blog/3099987

你可能感兴趣的:((详细代码,文末Demo下载)android简单修改密码、登录、注册功能 基于android 4.x...)