我有SQLite
命令这个问题。我正在尝试使用字符串进行查询,您可以在代码中看到。但我一直在犯这个错误。
public List<SignUpPOJO> fetchSignUpDetails(int value) {
this.open();
Cursor cursor = db.rawQuery(GET_TEACHER_DETAILS + value, null);
List<SignUpPOJO> list = new ArrayList<SignUpPOJO>();
while (cursor.moveToFirst()) {
do {
SignUpPOJO pojo = new SignUpPOJO();
pojo.setName(cursor.getString(0));
pojo.setDepartment(cursor.getString(1));
pojo.setClass_(cursor.getString(2));
pojo.setSubject(cursor.getString(3));
list.add(pojo);
} while (cursor.moveToNext());
cursor.close();
db.close();
}
return list;
}
帮助将不胜感激。
答案 0 :(得分:0)
自己解决了!只是评论了几行和瞧!
public List<SignUpPOJO> fetchLoginDetails(String value) {
this.open();
db = getReadableDatabase();
Cursor cursor = db.rawQuery(GET_USER_PASS + "'" + value + "'", null);
List<SignUpPOJO> list = new ArrayList<SignUpPOJO>();
// while (cursor.moveToFirst()) {
// do {
cursor.moveToNext();
SignUpPOJO pojo = new SignUpPOJO();
pojo.setName(cursor.getString(0));
pojo.setPassword(cursor.getString(1));
list.add(pojo);
// } while (cursor.moveToNext());
cursor.close();
db.close();
// }
return list;
}
基本上,我正在使用仅返回一个结果的_name
查询。