-1

I created a database file using the following code

// Get the documents directory
NSArray *dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docsDir = dirPaths[0];

// Build the path to the database file


databasePath = [[NSString alloc] initWithString: [docsDir stringByAppendingPathComponent:@"MyDB.db"]];

How can I remove the file "MyDB.db" ?

Thanks in advance.

Teja Nandamuri
  • 11,045
  • 6
  • 57
  • 109

1 Answers1

1

You can remove a file with the following

NSError *error;
if(![[NSFileManager defaultManager] removeItemAtPath:databasePath error:&error]) {
    NSLog(@"error while removing file: %@", error.localizedDescription);
}
Daniele
  • 2,461
  • 21
  • 16