c.getString(i+2)
不起作用;我错过了这些代码吗?
错误:java.lang.IllegalStateException: get field slot from row 0 col 13 failed
...
static String [] lesson_value;
String query = "SELECT id, tag, lesson1, lesson2, lesson3, lesson4, lesson5," +
" lesson6, lesson7, lesson8, lesson9, lesson10,lesson11 " +
"from mytable order by id DESC limit 1";
Cursor c = db.rawQuery(query,null);
if (c != null && c.moveToFirst()) {
for(int i=0; i<12; i++) {
if ( c.getString(i+2) != null ) {
lesson_value[i] = c.getString(i+2);
}
}
答案 0 :(得分:3)
我非常确定12
循环中的for
应该是11
。有11节课,索引2到12包括在内,因为你要加2,所以这意味着索引应该在0到10之间。
或者您可以在2到12之间运行for
循环,而无需添加两个:
for (i = 2; i <= 12; i++)
justUse (i);