Quote:
Originally Posted by GreenApple
Does anyone know?
|
NSArray *searchPaths =NSSearchPathForDirectoriesInDomains(NSDocumentDir ectory, NSUserDomainMask, YES);
NSString *documentFolderPath = [searchPaths objectAtIndex: 0];
dbFilePath = [documentFolderPath stringByAppendingPathComponent: @"Task.db"];
if (! [[NSFileManager defaultManager] fileExistsAtPath: dbFilePath]) {
//NSLog(@"didn't find db, need to copy");
NSString *backupDbPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Task.db"];
if (backupDbPath == nil) {
// couldn't find backup db to copy, bail
return NO;
} else {
BOOL copiedBackupDb = [[NSFileManager defaultManager]
copyItemAtPath:backupDbPath
toPath:dbFilePath
error:nil];
if (! copiedBackupDb) {
// copying backup db failed, bail
return NO;
}
}
this is the way i try to put my database to documents directory,....so i hope you will get some help