Database crash - can't close
I have a list that I am populating from a database. I am following the example found in the persistence app. This is the code:
var db = Titanium.Database.open('MyTable');
db.execute('CREATE TABLE IF NOT EXISTS labels (id INTEGER PRIMARY KEY, label TEXT)');
//Code that populates database if it doesn't exist
var dbData = db.execute('SELECT * FROM labels');
for(i=0;i<dbData.rowCount;i++){
labels.push(dbData.fieldByName('label'));
Ti.API.info(dbData.fieldByName('label'));
dbData.next();
}
dbData.close();
Everything works fine until I quit the application when I get the following stack trace saying that the db cannot be closed because implementations have leaked prepared statements.
If I add db.close();
to the code the same error is thrown.
I tried looking at different questions but I can't figure this out.
Any help is appreciated.
1 Answer
-
I would close the db after populating the data, and define db again to open the database before select, then close it again.