나는 SQLlite 데이터베이스를 사용하고있는 곳에서 App을 만들었습니다 ... 필요한 경우 NSCaches Directory에서 다음과 같은 방법으로 앱을 시작할 때 복사합니다 : 나는 그들이 옛 앱하지만 기존의 데이터베이스를 통해 새로운 응용 프로그램을 설치합니다 데이터베이스 - 파일에 STH을 변경하고 내 고객을위한 새로운 응용 프로그램 파일을 만들 경우iOS에서 SQLite DB를 덮어 쓰는 법
- (void) copyDatabaseIfNeeded {
//Using NSFileManager we can perform many file system operations.
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error;
NSString *dbPath = [self getDBPath];
BOOL success = [fileManager fileExistsAtPath:dbPath];
if(!success) {
NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"datenbankSpeed"];
success = [fileManager copyItemAtPath:defaultDBPath toPath:dbPath error:&error];
if (!success)
NSAssert1(0, @"Failed to create writable database file with message '%@'.", [error localizedDescription]);
}
}
- (NSString *) getDBPath {
//Search for standard documents using NSSearchPathForDirectoriesInDomains
//First Param = Searching the documents directory
//Second Param = Searching the Users directory and not the System
//Expand any tildes and identify home directories.
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory , NSUserDomainMask, YES);
NSString *documentsDir = [paths lastObject];
return [documentsDir stringByAppendingPathComponent:@"datenbankSpeed"];
}
내 문제는, 아직 사용,이다하는 충돌이 발생합니다!
나는 그 목적으로'PRAGMA user_version'을 사용할 수 있다고 생각합니다. –
정보 주셔서 감사합니다. 사용법을 설명하는 답변을 추가해야합니다. – Mar0ux
네, 훌륭하게 들리지만 정확히 내 사본에서 정확하게 수행하는 방법 데이터베이스 요구 사항! 예를 들려 줄 수 있습니까?! – davidOhara