开发者

Android how to close db when query execute

开发者 https://www.devze.com 2023-03-15 16:15 出处:网络
i have a websearch and db search ,this can be done at the same time , in db search am using db cursor for setting the result ,also for making search faster am open the db in OnCreate() and close it in

i have a websearch and db search ,this can be done at the same time , in db search am using db cursor for setting the result ,also for making search faster am open the db in OnCreate() and close it in onPause ,both the websearch and dbsearch runn开发者_运维百科ing in separate async task ,when websearch result comes first am starting new activity,if db query is still executing am not able to close the db, how can close the db in this situation ,please help me

i get the following exeception

android.database.sqlite.SQLiteException: Unable to close due to unfinalised statements


You may write DB operation in separate thread and start the result activity once thread execution completes.


You cannot force close the database.

You need to close all the cursors for the different queries you have running on that database.

Since your queries are running in separate ASyncTask, you need to keep track of those and cancel them (you can close the cursors in the onCancelled callback function)


i have opend the db in my application class and solved my problem

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号