【问题标题】:How to clear or manipulate cache.db data ios application如何清除或操作 cache.db 数据 ios 应用程序
【发布时间】:2013-06-10 16:52:51
【问题描述】:

我有一个通过 https 连接到服务器的 iOS phonegap 应用程序。在下面 (App_name)/Library/(BundleId)/Cache.db (cfurl_cache_response) 为客户端想要删除的用户存储了一些信息。我已经修复了存储问题,但我想在用户更新应用程序时删除 cache.db 中的旧存储信息。以编程方式可行吗?

【问题讨论】:

    标签: ios cordova


    【解决方案1】:
    BOOL isNotFirstTimeRun = [[NSUserDefaults standardUserDefaults] boolForKey:@"isnotfirsttimerun"];
    if (!isNotFirstTimeRun) {
        // Clear the cache if this is a first time run
        [[NSURLCache sharedURLCache] removeAllCachedResponses];
        // Set the flag to true and synchronize the user defaults
        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
        [defaults setBool:YES forKey: @"isnotfirsttimerun"];
        [defaults synchronize];
    }
    

    这在 didFinishLaunchingWithOptions 中为我完成了工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-01-30
      • 1970-01-01
      • 1970-01-01
      • 2011-04-21
      • 1970-01-01
      • 1970-01-01
      • 2011-06-18
      • 1970-01-01
      相关资源
      最近更新 更多