Howdy,
My app keeps crashing every time I try to execute a SQL query. Below is a snippet of code that should install a preexisting database called products.sqlite, open the database, then drop a table called products if it exists.
Ti.Database.install('products.sqlite', 'productDB'); var db = Ti.Database.open('productDB'); db.execute('DROP TABLE IF EXISTS products'); // Remove the products tableAm I installing or opening the database incorrectly? This is an iPad app on iOS 4.2.
2 Answers
Accepted Answer
Indeed, install does install and open the database. However, the apidocs explain that the arguments of Ti.Database.install are actually path and name.
This is explained in more detail in the SQLite Databases guide.
What if you combine the first two lines into:
var db = Ti.Database.install('products.sqlite', 'productDB');The install will do an install and/or open, so calling the open again might be the problem.
Your Answer
Think you can help? Login to answer this question!