我创建了一个非常简单的数据库安卓应用程序。它接受输入并显示结果。添加按钮用于添加输入,删除按钮用于从SQLite数据库中删除输入。我的Android SQLite中的游标已正确指向,但仍然出现错误:Caused by: java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.以下是游标部分:Cursor c = db.rawQuery(query, null)。
c.moveToFirst();
//Traversing through DB
while (!c.isAfterLast()){
if(c.getString(c.getColumnIndex("studentname")) !=null)
{
dbString += c.getString(c.getColumnIndex("studentname"));
dbString +="\n"; }
c.moveToNext(); }
db.close();
return dbString;
我已经尝试改变光标位置,但仍然出现相同的错误。我在其他网站上进行了研究,发现概念相同,但仍存在问题。