-
Notifications
You must be signed in to change notification settings - Fork 61
Open
Description
Thanks for library. But need to add database
pragma mark -
pragma mark - Copy DataBase Method
-(void)copyDatabaseToDocumentDirectoryWithName:(NSString *)name
{
NSString *path = [[NSBundle mainBundle]pathForResource:[[name lastPathComponent]stringByDeletingPathExtension] ofType:[name pathExtension]];
if ([[NSFileManager defaultManager] fileExistsAtPath:path])
{
NSArray *pathArray = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask,YES);
NSString *documentsDirectory = [pathArray objectAtIndex:0];
NSString *strFileDBPath = [documentsDirectory stringByAppendingPathComponent:name];
if ([[NSFileManager defaultManager] fileExistsAtPath:strFileDBPath])//File exists in document directory
{
NSLog(@"Database exists");
}
else //File doesnot exists in document directory
{
//Need to copy file in document directory
NSError *error = nil;
if ([[NSFileManager defaultManager] copyItemAtPath:path toPath:strFileDBPath error:&error])
{ //copied successfully
NSLog(@"Database copied");
}
else
{ //not copied
NSLog(@"Database not copied");
}
}
}
else
{
NSLog(@"Database file does not exists");
}
}
Metadata
Metadata
Assignees
Labels
No labels