Titanium Community Questions & Answer Archive

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

Where is the location of my sqlite database file?

hi everyone,

nowadays i am trying to make an app using sqlite database. from many sources i've read, titanium embeded sqlite on it. My qustions are when i wrote :

var db = Titanium.Database.open('testdb');

1 where is the location of my database file (something like .sqlite or .db or something like that) on my mac and windows directory if i deploy the app using simulator (iphone and android)?

2 what is the extension of the file?? (.sqlite or .db or kind like that)

3 where is the location of my database file if i install the app on device? may i move that file to external storage device like sdcard?

thx for answering



— asked November 19th 2010 by Wilson Wijaya
  • database
  • databases

1 Answer

  • Accepted Answer

    Hi Wijaya,

    On android, you can inspect your sql file by opening your workstation OS commandline/shell and entering these commands:

    • adb -e shell [this will take you to the emulator's shell. The commands are a bit limited, and sadly there is no commandline completion :( ]
    • cd /data/data/com.yourdomain.yourapp/databases/ [this is where your app's databases are created]
    • ls [your database file should have a .db extension]
    • sqlite3 <yourdatabase.db>
    • .help [to see sqlite3 help that will state which commands are available]

    So, for example, if you created a "todo" database like this:

    var db = Titanium.Database.open('todos');
    db.execute('CREATE TABLE IF NOT EXISTS todos \
    (id INTEGER PRIMARY KEY, todo TEXT)');

    1) your database file would be /data/data/com.yourdomain.yourapp/databases/todo.db

    2) the extension would be .db

    3) in your application, you could copy it to your removable storage using Titanium.Filesystem

    — answered November 19th 2010 by Paul Dowsett
    • Perhaps things have changed …

      'adb -e shell' on my (working Linux) system, give an error about no device being found.

      If I mount my device and navigate to /data/data/, my database is not there. Might it be somewhere else?

      Its fully functional and I am able to read and write to it from the emulator and deployed applications. But I'd like to be able to access the raw data tables for debugging / informational purposes. I have mounted my device and looked in every folder, and don't see it. If I run a 'find -name "*.db"' command on it, it finds a couple of others, but nothing associated with my application. I know its there, somewhere ;-) How to find it?


      — commented October 6th 2011 by Hal Burgiss
    • In my experience, databases created by Titanium under iOS have a *.sql extension, while databases created by Titanium under Android do not have an extension at all.

      — commented October 6th 2011 by Doug Handy
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.