0
我看到有很多类似的问题,但通过他们没有找到答案我的问题。SQLite数据库更新在iPhone应用程序
有一个使用sqlite数据库的iPhone应用程序。需要更新应用程序,一切都很顺利。 当我在iPhone上安装应用程序时,它工作正常,但是当我更新某些设备上已安装的应用程序时,它将我与旧数据库混合在一起,无法运行,直到我删除并再次安装应用程序。
我对设备检查数据的代码是:
/*
This method checks is rawdata has been copied to Documents directory.
If not, copies and returns YES, to start conversion.
Else, if already copied, reply NO.
*/
- (void) checkImportIsNeededFrom: (NSString*) bundledRawFilePath toDestination:(NSString*) documentSavedRawFilePath
{
NSLog(@"Checking rawdata file into Documents folder..");
if ([[NSFileManager defaultManager] fileExistsAtPath:documentSavedRawFilePath]) {
importIsNeeded = NO; // SET YES TO FORCE IMPORT ON EACH STARTUP
NSLog(@"copy already existing in %@", documentSavedRawFilePath);
} else {
[[NSFileManager defaultManager] copyItemAtPath:bundledRawFilePath toPath:documentSavedRawFilePath error:NULL];
importIsNeeded = YES;
NSLog(@"copy %@ to %@ done...", bundledRawFilePath, documentSavedRawFilePath);
}
}
- (BOOL) importIsNeeded {
return importIsNeeded;
}
所以,我只是需要一些帮助,删除设备上的旧的和新的替换它。有没有简单的解决方案。
谢谢。
是的,但每次更改数据库文件的名称时,都会启动导入。所以它以某种方式连接到sqlite数据库的名称。但我的问题是,当应用程序看到不同的名称来删除旧的数据库。我是iOS的初学者,所以不确定你是否了解我。 – Akosha