{ "id": "61193", "key": "TIMOB-561", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "11225", "name": "Release 1.5.0", "archived": true, "released": true, "releaseDate": "2010-12-14" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2011-04-17T01:53:30.000+0000", "created": "2011-04-15T02:31:57.000+0000", "priority": { "name": "Trivial", "id": "5" }, "labels": [ "android", "database", "feature", "open" ], "versions": [], "issuelinks": [], "assignee": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2011-04-17T01:53:30.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "{html}
We often need to download database files and store them in the\nappDataDirectory. It would be nice if we could simply call\nDB.open(\"filename\") and pass a fully-qualified path and filename to\nthe database.
\nWe should not be required to place databases in a specific\nfolder, nor should we be forced to append a \".sql\" extension to the\nend of a database filename.
This can be accomplished by\nTitanium.Database.openFile(...)
. I'm aware that the\ndocumentation on the Developer site is incorrect, but it should be\nfixed with the next release. Sorry for the inconvenience.
Whoops. Thought this was filed in Titanium Desktop. Need more\ncoffee. Reopening.
Any update on this? With the small amount of space available for\nmany Android devices, the ability to open a database stored on an\nSD card will be crucial for large databases.
For now it should be possible to use an absolute path to any\nreadable location on the filesystem, here's a gist I made that\nshows the example using a DB pushed onto the SD card:
\n\nI'm changing this bug to better reflect our API, i.e. we should\naccept a file object as well as a path string in our open() method\nso this works more consistently.
Note: Storing a database on the SDCard allows it to be used by\nany application on the system and or copied off by the user. App\nlevel security is not possible on SDCard.
(from [b01fdb396b2b89aa87506654379c3755047a649f])\nallow sqlite databases to be opened from File objects as well as\napp:// paths [#561 state:fixed-in-qa] \nhttp://github.com/appcelerator/titanium_mobile/commit/b01fdb396b2b8...
Is this available in the current nightly build? If not, where\ncan I get a copy of this code for testing?
It's in the nightly build.
test script
\nTi.API.info(\"db tst open att l16file:///sdcard/test.db\");
\nTi.API.info('for drillbit copy test.db to card');
\n//copy db to the sdcard
var file =\nTitanium.Filesystem.getFile(\"file:///sdcard/test.db\");
\nvar db = Ti.Database.open(file);
\nif ( db == null ) { alert('db null');}
\nTi.API.info( 'db ... ' + db );
\nvar rs = db.execute('SELECT message FROM test');
\nif ( rs != null && rs.isValidRow()) {
\nalert(rs.getFieldByName(\"message\"));
\n
\n}//end if else
\n{
\nalert('Select fail');
\n
\n}//end else
\nif ( rs != null ) rs.close();
\nif ( db != null ) db.close();
pass Titanium SDK version: 1.5.0 (12/07/10 10:00 8f4eea3...)\nAndroid, 1.6/2.1, code above