Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Quick Titanium Desktop Database Creation Tutorial

Figuring out how to use the Desktop APIs can be tough since they're not well documented and the code snippets (if there) may be out of date.

Anyway, Titanium.DB's code snippert suggests that the way to open a database is with a line of code similar to…

var db = Titanium.Database.openFile(Titanium.API.application.dataPath, "data.db");

This implies that the way to call it is with a two-part argument of the path and the file name, separated by a comma. And every time I've tried that, I've failed.

But the truth is, the meager API documentation says it only accepts a full path to a file. So I crunched the two togther…

adp = Titanium.API.Application.getDataPath();
dbpath = adp + "/thatlovely.db";
var db = Titanium.Database.openFile(dbpath);

This works. code after it executes and I can find it in the AppData directory on Windows 7.

— asked April 19th 2010 by Greg Bulmash
  • a
  • create
  • creation
  • database
  • html5
  • sqlite
  • titanium.db
1 Comment
  • This code works great when creating a database runtime, but what about when you have a database that you need to import?

    I can't seem to get this to import an existing db, pre-populated with data. Have you figured out how to do this?

    — commented January 3rd 2011 by C Lee

1 Answer

  • what i have to do for create new database in desktop.Let i have to create db name as 'mydatabase'.if i write
    Titanium.Database.open('mydatabase');
    then it doest not create it.Please help me out.

    — answered November 23rd 2011 by rajveer singh
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.