Android: how cancel/interrupt/break pending SQLite query?

走远了吗. 提交于 2019-12-06 03:09:50

You can't cancel pending sql query. It's done in SQLite engine. SQLite has native methods to interrupt query, but it's not accessible in java interface.

The best would be to improve query performance.
Read this: http://www.sqlite.org/cvstrac/wiki?p=PerformanceTuning

You can divide long running queries to smaller by limiting row number. Then it would be easier to cancel query that is performed in chunks.

ASyncTask supports cancellation and the flag should cancel all, including your SQL Query.

ASyncTask.cancel(boolean mayInterruptIfRunning)

SQLite provides a intrerupt method: http://www.sqlite.org/c3ref/interrupt.html

I'm not sure how you would call that in Android though.

You can cancel running queries on sqlite by using android.os.CancellationSignal which can be passed to some of the methods of android.database.sqlite.SQLiteDatabase

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!