我们可以同时从数据库中获取布尔值和字符串值吗?
请在下面查询我想要做同样的事情: -
if(uname.equals("") || uname == null){
Toast.makeText(getApplicationContext(), "Username Empty", Toast.LENGTH_SHORT).show();
}else if(pass.equals("") || pass == null){
Toast.makeText(getApplicationContext(), "Password Empty", Toast.LENGTH_SHORT).show();
}else{
Database ValidLogin = new Database(User.this);
ValidLogin.open();
boolean validLogin = ValidLogin.validate(uname, pass);
ValidLogin.close();
另外,找到以下数据库助手类: -
public boolean validate(String uname, String pass) {
// TODO Auto-generated method stub
// SELECT
String[] columns = { "_id" };
// WHERE clause
String selection = "user_name = ? AND _password = ?";
// WHERE clause arguments
String[] selectionArgs = { uname, pass };
Cursor cursor = ourDatabase.query(DATABASE_TABLE, columns, selection,
selectionArgs, null, null, null);
try {
if (cursor != null && cursor.getCount() > 0) {
return true;
}
} catch (Exception e) {
e.printStackTrace();
}
cursor.close();
return false;
请建议任何链接或解决方法吗?
提前谢谢你:)