HEH
HEH

Reputation: 305

How to clear or manipulate cache.db data ios application

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?

Upvotes: 2

Views: 3445

Answers (1)

HEH
HEH

Reputation: 305

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

That did the job for me in didFinishLaunchingWithOptions.

Upvotes: 5

Related Questions