SelectLogin
函数返回密码和电话等于输入密码和电话的用户。此查询返回数据库中的所有用户。什么问题?
public static ArrayList<User> selectLogin(String[] args){
ArrayList<User> users = new ArrayList<>();
String sql=String.format("SELECT * FROM %s WHERE %s =%s AND %s = %s;", TABLE_NAME,CLM_PASSWORD,args[0],CLM_PHONE,args[1]);
Cursor cursor=Config.database.rawQuery(sql,args);
while (cursor.moveToNext()) {
int id = cursor.getInt(cursor.getColumnIndex(CLM_ID));
String phone = cursor.getString(cursor.getColumnIndex(CLM_PHONE));
String password = cursor.getString(cursor.getColumnIndex(CLM_PASSWORD));
users.add(new User(id,phone,password));
}
return users;
}
private ArrayList<User> checkLoign(){
String[] args=new String[]{edtPassword.getText().toString(),edtPhone.getText().toString()};
ArrayList<User> users;
users=User.selectLogin(args);
return users;
}