0
我如何提前提供一个填充sqlite数据库CoreData预供应用程序与sqlite
像我会有一个应用程序。与已经包含项目数据库,而不只是下载数据在第一次启动
我可以替换为一个在使用SQLite,但我不知道如何创建sqlite的文件
-(void)importDatabaseToDocumentsDir
{
NSFileManager *fmngr = [[NSFileManager alloc] init];
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"Kalkulacka.sqlite" ofType:nil];
NSError *error;
if(filePath != nil && ![fmngr copyItemAtPath:filePath toPath:[NSString stringWithFormat:@"%@/Documents/%@", NSHomeDirectory(),@"Kalkulacka.sqlite"] error:&error]) {
// handle the error
//NSLog(@"Error creating the database: %@", [error description]);
}
[fmngr release];
}
感谢
解决方案是填充数据库:从设备中导出所有数据(使用组织器),将导出的数据重命名为zip,以便我可以遍历它并找到sqlite ...然后按照提及的方式导入它 – 2012-01-10 15:09:38