I\'ve been commissioned to update a native iOS app, but as we\'re also going to release it to other platforms, we\'re are writing the new version using Appcelerator\'s Titanium.
This should be possible (although it can get tricky) as long as the previous developers observed Apple rules on where the user information db was stored.
As long as you have the same bundle ID, and increment the version, you can overwrite the existing app during testing to simulate an update (make sure you are using an Ad-hoc distribution), this will leave the user files in place. From there, when you load your app for the first time, load that DB in the usual way:
// Set a property so you do this only one time when they first update
if(Ti.App.Properties.getBool('isDatabaseMigrated', false)) {
// See if the DB file exists (this may be a fresh install not an update)
var dbfile = Ti.Filesystem.getFile(Ti.Filesystem.applicationSupportDirectory+'/database', 'nameOfDB.sql');
if(dbfile.exists()) {
// Open the DB
var db = Ti.Database.open('nameOfDB');
.... Now do your thing ....
db.close();
}
// Set flag so we only check this once
Ti.App.Properties.setBool('isDatabaseMigrated', true);
}
iOS has a specific directory where they keep DB files, and the newest version of Titanium migrates any old DB's to this directory.