hi :) , I have 2 buttons ( install internal db & install remote db) ,
the problem is if i install the internal db first the the app will take it all the time even if install the remote db after , and also if i install the remote db first it will take it all the time even if i install the internal db after.
i have 2 diff db with same table but different numbers of rows on it ( i always delete the app from device and re-install to check )
my code : Install remote db button :
function takeRemoteDB() { c = Titanium.Network.createHTTPClient(); c.onload = function() { var filename ='Test1.sqlite'; var appDir = Titanium.Filesystem.applicationDataDirectory; var f = Titanium.Filesystem.getFile(appDir,filename); if (Titanium.Platform.name == 'android') { f.write(this.responseData); } }; c.open('GET','http://testtest.t15.org/Test1.sqlite'); c.file = Titanium.Filesystem.getFile(appDir,'Test1.sqlite'); c.send(); }and for the Internal db button :
function InternalDB() { var db = Ti.Database.install('/Test1.sqlite', 'Test1'); var a = db.execute('SELECT title FROM archive'); var counter=0 while (a.isValidRow()) // just to test the contents of the db { if (counter=0) label1.text = a.fieldByName('title')+'\n'; else{ label1.text += a.fieldByName('title')+'\n'; } counter++; a.next(); } a.close(); db.close(); }and this is just a function to show the content of the remote db after install it :
function contenOfRemoteDB () { var appDir = Titanium.Filesystem.applicationDataDirectory; var DBpath = appDir +'/Test1.sqlite'; var db = Ti.Database.install(DBpath, 'Test1'); var a = db.execute('SELECT title FROM archive'); var counter=0 while (a.isValidRow()) { if (counter=0) label1.text=a.fieldByName('title')+'\n'; else{ label1.text+=a.fieldByName('title')+'\n'; } counter++; a.next(); } a.close(); db.close(); }
my plan is to make internal db in the app and remote db for new contents ,
using Android 2.3 || ti build: 2.0.1.201204061639