0

数据库是只读的。

代码:

//获取数据库
    FMDatabase * db = [dataManager openDataBase];
    //判断数据库是否能打开
    if ([db open]) {
        //获取通话记录中所有的address
        FMResultSet * rs = [db executeQuery:@"SELECT address FROM privacy_call"];
        NSString * markaddress = nil;
        while ([rs next]) {
            NSString * address = [rs stringForColumn:@"address"];
            if ([self isEqualContactNumber:address withPrivacyNumber:number] && ![markaddress isEqualToString:address]) {
                markaddress = address;
                //删除数据
                BOOL resultSet = [db executeUpdate:@"DELETE FROM privacy_call WHERE address = ?",address];
                success = resultSet;
            }
        }
        [rs close];
    }
    else {
        NSLog(@"数据库打开错误");
        return NO;
    }
4

1 回答 1

0

很难理解问题是什么,

但如果我猜一下,这条线需要像这样更新:

//assuming executeUpdate returns a BOOL
BOOL success = [db executeUpdate:[NSString stringWithFormat:@"DELETE FROM privacy_call WHERE address = %@",address]];
于 2013-06-08T03:19:26.653 回答