[英]What's wrong with this SQLite query?
I can guarantee that the database has all the columns and values I am looking for. 我可以保证数据库具有我要查找的所有列和值。
The query comes back with a CursorOutOfBounds
. 该查询返回一个CursorOutOfBounds
。 Does anyone have any ideas why and what I should test? 有人对我为什么要测试什么有什么想法吗?
Cursor c = db.rawQuery("SELECT * FROM table WHERE _id="+nextvalue+"" , null);
c.moveToFirst();
numval = c.getInt(c.getColumnIndex("_id"));
c.close();
Logcat output Logcat输出
11-22 00:08:36.614: ERROR/AndroidRuntime(25405): Caused by: android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0
The query is returning an empty result set. 查询返回一个空结果集。 There are no records with the id of nextvalue
(whatever that is). 没有ID为nextvalue
记录(无论是什么)。 You should check that moveToFirst()
succeeded: 您应该检查moveToFirst()
成功:
if (c.moveToFirst()) {
numval = c.getInt(c.getColumnIndex("_id"));
} else {
// no results returned
}
c.close();
Does the statement is in bindview
of CursorAdapter ? 该语句是否在CursorAdapter的bindview
中? if it is, try to remove c.moveToFirst()
如果是,请尝试删除c.moveToFirst()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.