In my Android application user can fill database with imported data, then perform predefined, complex SQL query. With some data pattern, query will take very long (minutes and more on HTC Hero), while common usage will not exceed 10-15 seconds.
Is there any way to cancel pending SQLite query on Android? Timeout would be as good as well, partial results are not required. I'm performing query within AsyncTask.doInBackground()
I know best way is optimize query or change app logic, but in this case results depends on user knowledge anyway, so I'd like to help those who enter troublesome pattern.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With