iPhone SDK: How to copy a file from resources to documents Directory?:
You can copy a file or database from resources to documents directory by using the following code.
Code:
NSFileManager *fileMgr= [[NSFileManager alloc] init];
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"reporter.sqlite3" ofType:nil];
NSError *error;
if(![fileMgr copyItemAtPath:filePath toPath:[NSString stringWithFormat:@"%@/Documents/reporter.sqlite3", NSHomeDirectory()] error:&error]) {
//Exception Hndling
NSLog(@"Error : %@", [error description]);
}
[fileMgr release];
You can copy a file or database from resources to documents directory by using the following code.
Code:
NSFileManager *fileMgr= [[NSFileManager alloc] init];
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"reporter.sqlite3" ofType:nil];
NSError *error;
if(![fileMgr copyItemAtPath:filePath toPath:[NSString stringWithFormat:@"%@/Documents/reporter.sqlite3", NSHomeDirectory()] error:&error]) {
//Exception Hndling
NSLog(@"Error : %@", [error description]);
}
[fileMgr release];
0 comments:
Post a Comment
Share your thoughts here...