加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

关于SQLite,java.lang.IllegalStateException: attempt to re-o

发布时间:2020-12-12 19:31:45 所属栏目:百科 来源:网络整理
导读:java.lang.IllegalStateException: attempt to re-open an already-closed object: SQLiteQuery: select groupname from newGroupInfo order by _id desc limit ? offset ? at android.database.sqlite.SQLiteClosable.acquireReference(SQLiteClosable.java
java.lang.IllegalStateException: attempt to re-open an already-closed object: SQLiteQuery: select groupname from newGroupInfo order by _id desc limit ? offset ?
at android.database.sqlite.SQLiteClosable.acquireReference(SQLiteClosable.java:55)
at android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:58)
at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:152)at android.database.sqlite.SQLiteCursor.onMove(SQLiteCursor.java:124)
at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:214)
at android.database.AbstractCursor.moveToNext(AbstractCursor.java:245)
at com.example.invite.dao.AddGroupDao.findPart(AddGroupDao.java:97)

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的里面。以至于报错了。所以解决方法就是把他们放到外面去,记得要关闭,但位置要看清。这篇小博文就作为自己开始真正工作的起点,也方便自己回忆学习。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读