Reputation: 381
I have some trouble with installing a database with Ti.Database.install(). Here's what I'm doing:
Add some code to controllers/index.js
so the file looks like this
var db = Ti.Database.install('/testimusDB.sqlite', 'testimusDB');
var rs = db.execute('SELECT * FROM testimusTable');
db.close();
while (rs.isValidRow())
{
var name = rs.fieldByName('name');
var age = rs.fieldByName('age');
alert(name + ' is ' + age + 'years old');
rs.next();
}
rs.close();
$.index.open();
create a DB with FF Plugin SQLite Manager called testimusDB.sqlite and copy it to the REsources Folder of the Project
What I get is
Runtime Error: LOCATION: [101,19] ti:/invoker.js
MESSAGE: Uncaught Error: Resources/testimusDB.sqlite SOURCE: return
delegate.apply(invoker._thisObj_,args);
People with the same problem solved it by reducing the size of the DB (mine is 64 KB) or by using absolute path (I tried absolute-/relative- path and sqlite-/db-/sql- suffix). Any ideas how to solve this problem?
Upvotes: 1
Views: 1008
Reputation: 381
Okay I got it: You can't use install() when you're using alloy! (If anybody knows an official source for this information please let me know). You need to use models to sync the database. This guy and this guide helped me a lot.
Thanks for the answers.
Upvotes: 1
Reputation: 7028
Close connection to db at the end of operation:
rs.close();
db.close();
Size of the database doesn't matter. I'm using much bigger one: >10MB.
Upvotes: 0