2

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?

HEH
  • 305
  • 6
  • 15

1 Answers1

5
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.

HEH
  • 305
  • 6
  • 15