データベースは読み取り専用です。
コード:
//获取数据库
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;
}