i am newbie in iOS development, i make an application that contain SqliteDatabase i copy database feel from document directory like as
- (void) copyDatabaseIfNeeded {
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error;
NSString *dbPath = [self getDBPath];
BOOL success = [fileManager fileExistsAtPath:dbPath];
if(!success) {
NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"database.sqlite"];
success = [fileManager copyItemAtPath:defaultDBPath toPath:dbPath error:&error];
if (!success)
NSAssert1(0, @"Failed to create writable database file with message '%@'.", [error localizedDescription]);
}
}
- (NSString *) getDBPath
{
NSSearchPathForDirectoriesInDomains
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory , NSUserDomainMask, YES);
NSString *documentsDir = [paths objectAtIndex:0];
return [documentsDir stringByAppendingPathComponent:@"database.sqlite"];
}
Then it is working fine but now i want to make a .zip file of my database and fetch from it like as i make database.zip
file and in my .zip file it contain database.sqlite
file then how to fetch data from it. i want to make .zip file because my database size is to large and i use VACUUM
but my database size is refuse only few MB but i want more less size.
Thanks.
Aucun commentaire:
Enregistrer un commentaire