To delete a .db file in the Apps Document Directory.
The below code shows how to select that exact .db file and path, then remove it from the direcotory.
// create the path to access the document directory
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectoryPath = [paths objectAtIndex:0];
// create the path to access the 1st level under doucment directory
NSString *secondaryDirectoryPath = [documentsDirectoryPath
stringByAppendingPathComponent:@"secondary"];
// create the path to access database file
NSString *databaseFile = [secondaryDirectoryPath stringByAppendingPathComponent:@"database.db"];
// init fileManager and remove the database file
NSFileManager *fileManager = [NSFileManager defaultManager];
[fileManager removeItemAtPath:databaseFile error:NULL];
No comments:
Post a Comment