0 Flares 0 Flares ×Editor’s note: This blog post is a basic tutorial. The most up-to-date version is available in the wiki. Using the Titanium.Database.install method allows you to install a database that is pre-populated and packaged with the application in the resources directory. When the Titanium.Database.install method is called, it will install that database, or if the database is already installed, it will simply open the database.
- You can create a SQLite database in many ways – the easiest way might be to use the SQLite Manager plugin for Firefox located https://addons.mozilla.org/en-US/firefox/addon/5817.
- Place the resulting file in your resources folder and you will be able to use it with the install function:
var db = Titanium.Database.install('testdb.db','myDB');This will install the testdb.db database as myDB.sql in the databases directory which is available using:
Ti.Filesystem.applicationSupportDirectory+'/database'.From there you can now open that database using Ti.Database.open(‘myDB’); Always remember to close your database and result set when you are done accessing them.