调用 database.rawQuery 时出现 Android SQLiteMisuseException

标签 android sqlite exception

我在 Android 应用程序中使用 SQLite 数据库,有时在调用 database.rawQuery(String sql, String[] selectionArgs) 时会出现 SQLiteMisuseException。 这很奇怪,因为这个异常是随机出现的,我真的不知道为什么。

关于异常的更多信息:

android.database.sqlite.SQLiteMisuseException: library routine called out of sequence: , while compiling: SELECT PromoGuid, PromoViewCount FROM TablePromoView
at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:92)
at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:65)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:83)
at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:49)
at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:42)
at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1356)
at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1324)
at com.my.application....

有人遇到过这个错误吗?你能帮我解决一下吗?

提前致谢

PS:抱歉我的英语不好,我来自比利时

最佳答案

check this link .确保在开始其他 Activity 等之前关闭所有打开的数据库连接/游标。

关于调用 database.rawQuery 时出现 Android SQLiteMisuseException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8564609/

相关文章:

java - Android RecyclerView添加和删除项目

iphone - 如何将 sqlite3_column_blob 与 NSData 一起使用

java - Bean创建异常: Injection of autowired dependencies failed

android - 如何在 Android 中隐藏视频 View 的 Seekbar 或 Progressbar

android - 很棒的用户界面 UI 示例?截图

android - ProgressBar 未在某些设备中显示

string - Sqlite 将字符串转换为日期

ios - 关注 : How to use FTS in SQLite with Monotouch for iOS

unit-testing - TDD 如何处理异常和参数验证?

exception - Kotlin 协程无法处理异常