Skip to content

Instantly share code, notes, and snippets.

@yeahq
Created April 15, 2012 10:03
Show Gist options
  • Save yeahq/2391656 to your computer and use it in GitHub Desktop.
Save yeahq/2391656 to your computer and use it in GitHub Desktop.
How to copy a file from resources to documents?
// 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