【问题标题】:Using TiShadow can I delete the cache on EVERY file change?使用 TiShadow 可以在每次文件更改时删除缓存吗?
【发布时间】:2015-09-07 15:54:20
【问题描述】:

我在我的 Appcelerator Studio 项目目录中运行此命令 titanium build -p ios -T simulator --shadow,结果 iOS 模拟器启动,我的应用程序启动并运行。

不过,我有一个 SQLite 数据库和一些我希望调试的其他文件。 因此,我希望在重新启动应用程序时删除我的所有应用程序数据。 (即在每个文件保存时)

我该怎么做?

谢谢。

【问题讨论】:

  • 不适用于 TiShadow。您实际上需要重新初始化数据库。要么完全删除 SQL,要么在代码中删除它,然后重新启动

标签: mobile titanium appcelerator tishadow


【解决方案1】:

要在代码中删除它,您可以快速执行:

var db = Ti.Database.open('_alloy_');
var deleteRecords = db.execute('DELETE FROM dbnane');
Ti.API.info('Rows: ' + db.getRowsAffected());
db.close();

【讨论】:

    【解决方案2】:

    migas 回答很好,但我最终还是这样做了:

    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
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-04-29
      • 1970-01-01
      • 1970-01-01
      • 2018-02-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多