Android:如何取消/中断/中断待处理的SQLite查询? [英] Android: how cancel/interrupt/break pending SQLite query?

查看:173
本文介绍了Android:如何取消/中断/中断待处理的SQLite查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Android应用程序中,用户可以用导入的数据填充数据库,然后执行预定义的复杂SQL查询.使用某些数据模式,查询将花费很长时间(在HTC Hero上需要花费几分钟甚至更长的时间),而通常的使用时间不会超过10-15秒.

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.

有什么方法可以取消Android上待处理的SQLite查询吗?超时也将很好,不需要部分结果.我正在AsyncTask.doInBackground()

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.

推荐答案

您无法取消待处理的SQL查询.这是在SQLite引擎中完成的. SQLite具有本机方法来中断查询,但是无法在Java接口中访问.

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.

最好是提高查询性能.
阅读此内容: http://www.sqlite.org/cvstrac/wiki?p=PerformanceTuning

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.

这篇关于Android:如何取消/中断/中断待处理的SQLite查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆