0

I'm running this command titanium build -p ios -T simulator --shadow in my Appcelerator Studio project dir and as a result the iOS simulator launches and my app is up and running.

The thing though, is that I have a SQLite db and a few other files which I wish to debug. As a result, I want ALL my app data to be deleted whenever I relaunch the app. (that is on every file save)

How can I do that?

Thank you.

SudoPlz
  • 20,996
  • 12
  • 82
  • 123
  • 1
    not with TiShadow. You actually need to re-initialize the database. Either completely remove the SQL, or in code remove it, and re-initiate – Rene Pot Sep 07 '15 at 16:05

2 Answers2

0

To remove it in code you can quickly do:

var db = Ti.Database.open('_alloy_');
var deleteRecords = db.execute('DELETE FROM dbnane');
Ti.API.info('Rows: ' + db.getRowsAffected());
db.close();
miga
  • 3,997
  • 13
  • 45
0

migas answer was good but I finally ended up doing that:

if(Alloy.Globals.debugMode){    //if we are debugging
    //find the file
    var f = Ti.Filesystem.getFile(Ti.Filesystem.applicationSupportDirectory, "myDb.sql");

    if(f.exists() == true){     //If it's there
         f.deleteFile();        //just delete it
    }
}
SudoPlz
  • 20,996
  • 12
  • 82
  • 123