W mojej aplikacji użyłem DB sqlite. Przesłałem wersję 1.0 aplikacji do sklepu z aplikacjami. Ale potem zrobiłem kilka zmian w DB, takich jak Wstawianie nowych wierszy.Skopiuj Zaktualizowaną bazę danych do urządzenia w ios sdk
Następnie przesłano wersję 1.1 aplikacji. But i will not able to get updated DB because the old DB already exists in device.
Jak mogę to rozwiązać?
Po usunięciu aplikacji & zainstaluj nową wersję aplikacji, a następnie zaktualizuję bazę danych.
//My code for copy of DB is as follow:
- (void)createEditableCopyOfDatabaseIfNeeded
{
// First, test for existence.
BOOL success;
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:@"xxx.sqlite"];
success = [fileManager fileExistsAtPath:writableDBPath];
if (success) return;
// The writable database does not exist, so copy the default to the appropriate location.
NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"xxx.sqlite"];
success = [fileManager copyItemAtPath:defaultDBPath toPath:writableDBPath error:&error];
if (!success) {
NSAssert1(0, @"Failed to create writable database file with message '%@'.", [error localizedDescription]);
}
}
nazwałem tę metodę w sposób appDidFinishLaunching.
Jak mogę uzyskać zaktualizowane DB bez usuwania aplikacji, gdy nowa wersja jest dostępna
Wielkie dzięki! Wow, świetny pomysł, żeby to zrobić bardzo łatwo. – AtWork