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
精彩评论