I've got Fragments, where I cache data in every Fragment. I cache the data in an AsyncTask by downloading it in the doInBackground method from a server and save it in the onPostExecute to my database. So I always open the database connection in the onPostExecution. If I scroll "fast" threw the fragments, I think the AsyncTasks are pass the previews instances and there will be a android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:224) in the row, where I open the connection (getting dbHelper.getWritableDatabase())
I think there are two ways to solve this:
the onPostExecution method have to wait until the previews AsyncTask (onPostExecution) is finish
there's a way to use the same database connection for all instances of the AsyncTask, without locking them eachother
Is this correct? Somebody an idea, how to do this?