package com.example.jidanci;import androidx.appcompat.app.AppCompatActivity;import android.content.ContentValues;import android.content.Intent;import android.database.Cursor;import android.database.sqlite.SQLiteDatabase;import android.os.Bundle;import android.view.View;import android.widget.Button;import android.widget.EditText;import android.widget.Toast;import static android.widget.Toast.LENGTH_SHORT;public class update extends AppCompatActivity { private EditText ed1,ed2,ed3; private Button bt1; private DBHelper dbh; private SQLiteDatabase db; private Cursor cu; private String user,pawd,repawd; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_update); bt1 = findViewById(R.id.qrxg); ed1 = findViewById(R.id.xgyhmc); ed2 = findViewById(R.id.xgxmm); ed3 = findViewById(R.id.qrxmm); bt1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { goup(); } }); } private void goup() { user = ed1.getText().toString().trim(); pawd = ed2.getText().toString().trim(); repawd =ed3.getText().toString().trim(); boolean qrxg = false; if (user.equals("")) { Toast.makeText(update.this, "请填写账号", LENGTH_SHORT).show(); } else if (pawd.equals("")) { Toast.makeText(update.this, "请填写新密码", LENGTH_SHORT).show(); } else if (repawd.equals("")) { Toast.makeText(update.this, "请重新填写新密码", LENGTH_SHORT).show(); } else { dbh = new DBHelper(update.this,"db",null,1); db = dbh.getWritableDatabase(); cu = db.query("xinxi", new String[]{"username"}, null, null, null, null, null); while (cu.moveToNext()) { if (user.equals(cu.getString(cu.getColumnIndex("username")))) { if (pawd.length() == 6) { if (pawd.equals(repawd)) { ContentValues values = new ContentValues(); values.put("password", pawd); String where = "username=" + user + ""; db.update("xinxi", values, where, null); qrxg = true; db.close(); ed1.setText(""); ed2.setText(""); ed3.setText(""); break; } else { Toast.makeText(update.this, "两次密码不匹配", LENGTH_SHORT).show(); } } else { Toast.makeText(update.this, "请输入六位数的密码", LENGTH_SHORT).show(); break; } } else { Toast.makeText(update.this, "该用户不存在", LENGTH_SHORT).show(); break; } } } if(qrxg){ bt1.setText("立即登录"); bt1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String qrusername = ed1.getText().toString().trim(); String qrpawd = ed2.getText().toString().trim(); String qrrepawd =ed3.getText().toString().trim(); dbh = new DBHelper(update.this,"db",null,1); db = dbh.getWritableDatabase(); if(!qrusername.equals("")&&!qrpawd.equals("")&&!qrrepawd.equals("")){ cu = db.query("xinxi",new String[]{"username","password"},null,null,null,null,null); while (cu.moveToNext()){ if (qrusername.equals(cu.getString(cu.getColumnIndex("username")))) { if (qrpawd.equals(cu.getString(cu.getColumnIndex("password")))) { if(qrpawd.equals(qrrepawd)){ Intent tz = new Intent(update.this,loginActivity.class); startActivity(tz); Toast.makeText(update.this,"欢迎进入查询界面!!!", LENGTH_SHORT).show(); finish(); return; } else { Toast.makeText(update.this,"两次密码不匹配", LENGTH_SHORT).show(); } } else { Toast.makeText(update.this,"密码错误!!!", LENGTH_SHORT).show(); break; } } else{ Toast.makeText(update.this,"用户名称错误!!!", LENGTH_SHORT).show(); break; } } } else{ Toast.makeText(update.this,"请完整填写信息!!!", LENGTH_SHORT).show(); } } }); } }}
这个是AndroidStudio 的一段代码,里面的while死循环了,本来里面的数据库是有数据了,但是它的光标不向下个数据移动,但是我又找不到它是因为什么地方,开始死循环了。
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答 默认 最新
悬赏问题
- ¥15 三向应力状态求剪应力
- ¥15 jupyter notebook如何添加libGL.so.1库
- ¥20 easyPoi能否实现下拉多选或者复选框
- ¥15 网桥在转发帧时,会变帧的源地址和目的地址吗?
- ¥15 用Multisim设计汽车尾灯控制电路
- ¥100 求用matlab求解上述微分方程的程序代码
- ¥15 MAC安装佳能LBP2900驱动的网盘提取码
- ¥400 微信停车小程序谁懂的来
- ¥15 ATAC测序到底用什么peak文件做Diffbind差异分析
- ¥15 安装ubantu过程中第一个vfat 文件挂载失败