My app has several AsyncTaskRunners which are constantly access the database. I keep getting ThreadPool errors because of a closed database instance. Originally I had a new instance opened and then closed again, each with a different name every time. So every method that accessed the database would open its very open instance do whatever and then close that instance.
I was hoping that it would have been more efficient to open a single instance and then not close it so that every method within the AsyncTask would just do its thin with the database.
Is there a way to open a database instance when the app starts and not close it, and then get & put throughout the entire application just be referencing that instance?
Or is there a way to open an instance for my AsyncTaskRunner class so that all methods in that class can talk to the database?
I have tried initializing a database instance at the beginning of the class with
SQLDatabase db;
and then later in the doInBackground() I would open an instance of db and not close it. Then the various methods would try to talk to the db but with no success.