My Activity opens a database in onResume() and close it in onPause(). When Activity starts, many AsyncTasks which use that database execute. When I pressed Back button, database was closed and errors appear because AsyncTask is using it. What is solution for this problem?
My Activity opens a database in onResume() and close it in onPause(). When Activity
Share
Don’t close the database. Have your db helper class be a singleton and access it from your activities as needed. When you process dies, the database will be properly closed. Do make sure you are closing your cursors though.