Android AsyncTask and SQLite DB instance

后端 未结 3 1498
温柔的废话
温柔的废话 2020-12-23 23:50

I have a problem and I am not sure how to approach it. An activity in my app has multiple AsyncTasks which access single SQLiteOpenHelper. I initia

3条回答
  •  爱一瞬间的悲伤
    2020-12-24 00:25

    You mentioned that you cancel the AsyncTask before closing the DB. But you should keep in mind that cancelling the AsyncTask just signals the task to be cancelled and you need to check isCancelled() in doInBackground() and do the needful to stop DB operations.

    Before closing the DB, you then need to check getStatus() to be sure that the AsyncTask has stopped.

提交回复
热议问题