1

I have some trouble with installing a database with Ti.Database.install(). Here's what I'm doing:

  • Open new default alloy project
  • 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

  • Start the App via Titanium Studio on a Samsung S3

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?

4

2 回答 2

1

好的,我明白了:使用合金时不能使用 install()!(如果有人知道此信息的官方来源,请告诉我)。您需要使用模型来同步数据库。这个人和这个指南对我帮助很大。

感谢您的回答。

于 2013-11-04T19:49:09.553 回答
0

在操作结束时关闭与 db 的连接:

rs.close();
db.close();

数据库的大小无关紧要。我正在使用更大的一个:> 10MB。

于 2013-11-03T23:19:10.547 回答