My application give me this warning
A SQLiteConnection object for database \'+data+data+com_example_test+database\' was leaked! Please fix your ap
Probably you forgot to remove the break point of debugging sample:
In my case the error was caused when y try to download new data and database should be updated.
I solved it instantiating the database by calling a SELECT 0
. That cause database to be updated, so after that I try to download the new data. And worked fine.
Just drag that db.close
up into the finally
block.
Possible Solutions:
not committed the transactions
you have started (You should
always close the transaction once you started)Sqlite
(Looks like you have done this step from the code you posted)db.close
to finally
blockdb.close
on a database before deleting it with context.deleteDatabase(...)
and then recreating it with dbHelper.getWritableDatabase()
//Inside your SQLite helper class
@Override
public synchronized void close () {
if (db != null) {
db.close();
super.close();
}
}
//Inside the activity that makes a connection to the helper class
@Override
protected void onDestroy () {
super.onDestroy();
//call close() of the helper class
dbHelper.close();
}