Using TiShadow can I delete the cache on EVERY file change?

55 views Asked by At

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.

2

There are 2 answers

0
SudoPlz On BEST ANSWER

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
    }
}
0
miga On

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();