from:http://www.mobiletrain.org/lecture/doc/iphone/2011-08/677.html
-(void)copyFileDatabase
{
NSArray *paths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory,NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *documentLibraryFolderPath = [documentsDirectory stringByAppendingPathComponent:@"elimimation"];
if ([[NSFileManager defaultManager] fileExistsAtPath:documentLibraryFolderPath]) {
NSLog(@"文件已经存在了");
}else {
NSString *resourceSampleImagesFolderPath =[[NSBundle mainBundle]
pathForResource:@"elimimation"
ofType:@"sqlite"];
NSData *mainBundleFile = [NSData dataWithContentsOfFile:resourceSampleImagesFolderPath];
[[NSFileManager defaultManager] createFileAtPath:documentLibraryFolderPath
contents:mainBundleFile
attributes:nil];
}
}
-(void)deleteFileDatabade
{
NSArray *paths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory,NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *documentLibraryFolderPath = [documentsDirectory stringByAppendingPathComponent:@"elimimation"];
[[NSFileManager defaultManager] delete:documentLibraryFolderPath];
}