- (NSString *) copyDatabaseToDocuments {
NSFileManager *fileManager = [NSFileManager defaultManager];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
NSString *documentsPath = [paths objectAtIndex:0];
NSString *filePath = [documentsPath stringByAppdendingPathComponent:@"dbfile.sqlite"];

if ( ![fileManager fileExistsAtPath:filePath] ) {
NSString *bundlePath = [ [ [NSBundle mainBundle] resourcePath]
stringByAppendingPathComponent:@"dbfile.sqlite"];
[fileManager copyItemAtPath:bundlePath toPath:filePath error:nil];
}
return filePath;
}

+ Recent posts