这是完整的方法。之后我使用了第二种方法GetSQLiteDatabaseRecords();用于在edittext中显示结果。 + value_spinner +和+ date_value +是分别存储来自微调器和按钮的值的字符串。
GetSQliteQuery = "SELECT * FROM attendance where name ='"+value_spiner+"'AND date='"+date_value+"'";
_db = openOrCreateDatabase("employee.db", Context.MODE_PRIVATE, null);
cursor = _db.rawQuery(GetSQliteQuery, null);
if (cursor != null&& cursor.moveToFirst()){
// cursor.moveToFirst();
GetSQLiteDatabaseRecords();
}else{
Toast.makeText(Lunch_timeout.this, "No match", Toast.LENGTH_SHORT).show();
}
private void GetSQLiteDatabaseRecords()
{
in_time.setText(cursor.getString(3).toString());
}
我也是这样使用过的。 `
cursor=_db.query(true, mydb.TABLE_Attendance, new String[] {
mydb.ATT_COL_4,},
mydb.ATT_COL_2 + "=?" + " and " +
mydb.ATT_COL_3 + "=?",
new String[] {value_spiner,date_value},
null, null, null , null);
if ( cursor.moveToFirst()){
do {
GetSQLiteDatabaseRecords();
}while (cursor.moveToNext());
}else{
Toast.makeText(Lunch_timeout.this, "No match", Toast.LENGTH_SHORT).show();
}`
答案 0 :(得分:-2)
试试这个 -
GetSQliteQuery = "SELECT * FROM attendance where name ='"+value_spiner+"' AND date='"+date_value+"'";