Created
April 15, 2012 10:03
-
-
Save yeahq/2391656 to your computer and use it in GitHub Desktop.
How to copy a file from resources to documents?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// From: http://stackoverflow.com/questions/4743317/iphone-how-to-copy-a-file-from-resources-to-documents | |
NSFileManager *fmngr = [[NSFileManager alloc] init]; | |
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"mydb.sqlite" ofType:nil]; | |
NSError *error; | |
if(![fmngr copyItemAtPath:filePath toPath:[NSString stringWithFormat:@"%@/Documents/mydb.sqlite", NSHomeDirectory()] error:&error]) { | |
// handle the error | |
NSLog(@"Error creating the database: %@", [error description]); | |
} | |
[fmngr release]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment