java.lang.IllegalStateException: attempt to re-open an already-closed object: sqliteQuery: select groupname from newGroupInfo order by _id desc limit ? offset ?
@H_
502_2@
at android.database.sqlite.sqliteClosable.acquireReference(sqliteClosable.java:55)
@H_
502_2@
at android.database.sqlite.sqliteQuery.fillWindow(sqliteQuery.java:58)
@H_
502_2@
at android.database.sqlite.sqliteCursor.fillWindow(sqliteCursor.java:152)at android.database.sqlite.sqliteCursor.onMove(sqliteCursor.java:124)
@H_
502_2@
at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:214)
@H_
502_2@
at android.database.AbstractCursor.moveToNext(AbstractCursor.java:245)
@H_
502_2@
at com.example.invite.dao.AddGroupDao.findPart(AddGroupDao.java:97)
@H_
502_2@
at com.example.invite.MainActivity$2.run(MainActivity.java:96)
原文:while (cursor.moveToNext()) {
MyGroupInfo myGroupInfo = new MyGroupInfo();
String groupname = cursor.getString(0);
// myGroupInfo.setGroupName(cursor.getString(0));
myGroupInfo.setGroupName(groupname);
myGroupInfos.add(myGroupInfo);
cursor.close();
db.close();
}
看了一下,原来我的sqliteDatabase对象关闭放在了while的里面。以至于报错了。所以解决方法就是把他们放到外面去,记得要关闭,但位置要看清。这篇小博文就作为自己开始真正工作的起点,也方便自己回忆学习。