Android:如何取消/中断/中断待处理的SQLite查询?

编程入门 行业动态 更新时间:2024-10-26 14:34:24
本文介绍了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.

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

The best would be to improve query performance. Read this: www.sqlite/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查询?

本文发布于:2023-11-27 04:39:27,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1636630.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Android   SQLite

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!