dimanche 17 janvier 2016

clean database after logout IOS

how i clean the database.db file in logout method. I create the file in this init function. I tried NSFileManager delete and it didn't work.

-(id)init{
    self = [super init];
    if (self) {
        NSFileManager* fileManager = [NSFileManager defaultManager];

        NSArray* paths = [fileManager URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask];

        NSURL* directoryUrl = [paths objectAtIndex:0];

        NSURL* fileUrl = [directoryUrl URLByAppendingPathComponent:@"database.db"];

        NSString* filePath = [fileUrl path];

        const char* cFilePath = [filePath UTF8String];

        int res = sqlite3_open(cFilePath,&database);

        if(res != SQLITE_OK){
            NSLog(@"ERROR: fail to open db");
            database = nil;
        }

        [GroupSql createGroupTable:database];
        [LastGroupUpdateSql createGroupTable:database];
    }
    return self;
}

Aucun commentaire:

Enregistrer un commentaire