2

I have a DownLoadData class which extends async task, used for downloading master data from a web service. 10 masters tables are there in the SQLite database and each require seperate web service calls. So, in the DownLoadData task, I have 10 threads. Each will call the respective webservices, receive data and then insert it to the respective tables.

I start the transaction at _onPreExecute()_ and after checking if all the threads has finished , I end the transaction at _onPostExecute()_.

Problem is, this approach worked perfectly for versions till ICS. It doesn't seem to work in JellyBean. The app just hangs with this logcat message every 60 seconds :

04-02 14:53:23.263: W/SQLiteConnectionPool(1409): The connection pool for database '/data/data/com.c2info.liveorder/databases/DB' has been unable to grant a connection to thread 117 (AsyncTask #2) with flags 0x1 for 30.010002 seconds.

04-02 14:53:23.263: W/SQLiteConnectionPool(1409): Connections: 0 active, 1 idle, 0 available.

I begin and end the transaction like this :

public LocalDatabase beginTransact() {

  mdbHelper = new DatabaseHelper(ctx);
  mdb = mdbHelper.getWritableDatabase();
  execSQL("BEGIN");
  return this;
}

public void endTransact() {

  execSQL("END");
  mdbHelper.close();
}

I'm also using the same DB instance accross all threads.

Praful Bhatnagar
  • 7,425
  • 2
  • 36
  • 44
desidigitalnomad
  • 1,443
  • 21
  • 33

1 Answers1

0

I overcame the problem in JellyBean by treating each individual thread as a single transaction rather than a single transaction for all the threads

desidigitalnomad
  • 1,443
  • 21
  • 33