我没有从sqlite数据库获取数据。我在iPhone浏览器中检查过:数据库名称存在,但大小不存在。
我的代码:
-(NSString*)getdestinationPath{
NSArray *pathsArray=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
NSString *doumentDirectoryPath=[pathsArray objectAtIndex:0];
NSString *destinationPath=[doumentDirectoryPath stringByAppendingPathComponent:dataBaseName];
return destinationPath;
}
//--check availability of database--//
-(void)chkAndCreateDatbase{
NSFileManager *fileManger=[NSFileManager defaultManager];
NSError *error;
NSString *destinationPath=[self getdestinationPath];
if ([fileManger fileExistsAtPath:destinationPath]){
return;
}
NSString *sourcePath=[[[NSBundle mainBundle] resourcePath]stringByAppendingPathComponent:dataBaseName];
[fileManger copyItemAtPath:sourcePath toPath:destinationPath error:&error];
}