如何清除或操纵cache.db数据ios应用程序 [英] How to clear or manipulate cache.db data ios application

查看:1974
本文介绍了如何清除或操纵cache.db数据ios应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have an iOS phonegap application that connects to a server via https. Under (App_name)/Library/(BundleId)/Cache.db (cfurl_cache_response) stored some info for users that the client wanted to delete. I have fixed the storing issue but i want to delete the old stored info in cache.db when users update the application. Is that feasible programmatically?

推荐答案

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中为我完成了这项工作。

That did the job for me in didFinishLaunchingWithOptions.

这篇关于如何清除或操纵cache.db数据ios应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆