Created
December 4, 2012 15:58
-
-
Save dragthor/4205461 to your computer and use it in GitHub Desktop.
iOS get resource path for writing sqlite3 database
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
// Get documents directory | |
NSString *documentsDirectory = nil; | |
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); | |
documentsDirectory = [paths objectAtIndex: 0]; | |
NSString *targetPath = [documentsDirectory stringByAppendingPathComponent:@"todo.db"]; | |
if (![[NSFileManager defaultManager] fileExistsAtPath: targetPath]) { | |
NSString *sourcePath = [[NSBundle mainBundle] pathForResource:@"todo" ofType:@"db"]; | |
[[NSFileManager defaultManager] copyItemAtPath:sourcePath toPath:targetPath error:nil]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment