Skip to content Skip to sidebar Skip to footer

Android Sqlite Leaked Error

I've got my database connection setup in an Application but LogCat keep's telling me about a SQLite leak 04-25 11:22:23.771: W/SQLiteConnectionPool(9484): A SQLiteConnection object

Solution 1:

What is this DBAdapter class you're using? I don't know what it's doing so I don't know if it's correct. You should check where the SQLiteConnection object is obtained that the error message refers to, and ensure that that SQLiteConnection is close()d.

Are you getting the error only occasionally or all the time? It's probably not the main problem you are observing, but your code also fails to call close() when there is an exception before the close(). You should ensure close() gets called regardless of exception path by guarding it with a try/finally block:

dba.open();
try {
  Cursorc= ...;
  try {
    ...
  } finally {
    c.close();
  }
} finally {
  dba.close();
}

Solution 2:

Your problem is that you have to "Close" the database once you finished your database operation. So close your DB wherever you opened your DB.

Solution 3:

in DBAdapter class, in close function replace DBHelper.close() from db.close();

publicvoidclose() {
    DBHelper.close();
}

replace with the below;

publicvoidclose() {
    db.close();
}

Post a Comment for "Android Sqlite Leaked Error"