Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-561] Request: ability to open DB from any path and filename

GitHub Issuen/a
Resolution Date2011-04-17T01:53:30.000+0000
Affected Version/sn/a
Fix Version/sRelease 1.5.0
Labelsandroid, database, feature, open
AssigneeDon Thorp


We often need to download database files and store them in the appDataDirectory. It would be nice if we could simply call DB.open("filename") and pass a fully-qualified path and filename to the database.

We should not be required to place databases in a specific folder, nor should we be forced to append a ".sql" extension to the end of a database filename.


  1. Martin Robinson 2011-04-15

    This can be accomplished by Titanium.Database.openFile(...). I'm aware that the documentation on the Developer site is incorrect, but it should be fixed with the next release. Sorry for the inconvenience.

  2. Martin Robinson 2011-04-15

    Whoops. Thought this was filed in Titanium Desktop. Need more coffee. Reopening.

  3. Burggraf 2011-04-15

    Any update on this? With the small amount of space available for many Android devices, the ability to open a database stored on an SD card will be crucial for large databases.

  4. Marshall Culpepper 2011-04-15

    For now it should be possible to use an absolute path to any readable location on the filesystem, here's a gist I made that shows the example using a DB pushed onto the SD card:


    I'm changing this bug to better reflect our API, i.e. we should accept a file object as well as a path string in our open() method so this works more consistently.

  5. Don Thorp 2011-04-15

    Note: Storing a database on the SDCard allows it to be used by any application on the system and or copied off by the user. App level security is not possible on SDCard.

  6. Marshall Culpepper 2011-04-15

    (from [b01fdb396b2b89aa87506654379c3755047a649f]) allow sqlite databases to be opened from File objects as well as app:// paths [#561 state:fixed-in-qa] http://github.com/appcelerator/titanium_mobile/commit/b01fdb396b2b89aa87506654379c3755047a649f"> http://github.com/appcelerator/titanium_mobile/commit/b01fdb396b2b8...

  7. Burggraf 2011-04-15

    Is this available in the current nightly build? If not, where can I get a copy of this code for testing?

  8. Don Thorp 2011-04-15

    It's in the nightly build.

  9. Matt Schmulen 2011-04-15

    test script

    Ti.API.info("db tst open att l16file:///sdcard/test.db");
    Ti.API.info('for drillbit copy test.db to card');
    //copy db to the sdcard

    var file = Titanium.Filesystem.getFile("file:///sdcard/test.db");
    var db = Ti.Database.open(file);
    if ( db == null ) { alert('db null');}
    Ti.API.info( 'db ... ' + db );
    var rs = db.execute('SELECT message FROM test');
    if ( rs != null && rs.isValidRow()) {


    }//end if else

       alert('Select fail');

    }//end else

    if ( rs != null ) rs.close();
    if ( db != null ) db.close();

  10. Matt Schmulen 2011-04-15

    pass Titanium SDK version: 1.5.0 (12/07/10 10:00 8f4eea3...) Android, 1.6/2.1, code above

JSON Source