class ApkProvider extends FDroidProvider {

    @Override
    public int update(@NonNull Uri uri, ContentValues values, String where, String[] whereArgs) {
        if (MATCHER.match(uri) != CODE_APK_FROM_REPO) {
            throw new UnsupportedOperationException("Cannot update anything other than a single apk.");
        }

        boolean saveAntiFeatures = false;
        String[] antiFeatures = null;
        if (values.containsKey(Cols.AntiFeatures.ANTI_FEATURES)) {
            saveAntiFeatures = true;
            String antiFeaturesString = values.getAsString(Cols.AntiFeatures.ANTI_FEATURES);
            antiFeatures = Utils.parseCommaSeparatedString(antiFeaturesString);
            values.remove(Cols.AntiFeatures.ANTI_FEATURES);
        }

        validateFields(Cols.ALL, values);
        removeFieldsFromOtherTables(values);

        QuerySelection query = new QuerySelection(where, whereArgs);
        query = query.add(querySingleWithAppId(uri));

        int numRows = db().update(getTableName(), values, query.getSelection(), query.getArgs());

        if (saveAntiFeatures) {
            // Get the database ID of the row we just updated, so that we can join relevant anti features to it.
            Cursor result = db().query(getTableName(), new String[]{Cols.ROW_ID},
                    query.getSelection(), query.getArgs(), null, null, null);
            if (result != null) {
                result.moveToFirst();
                long apkId = result.getLong(0);
                ensureAntiFeatures(antiFeatures, apkId);
                result.close();
            }
        }

        if (!isApplyingBatch()) {
            getContext().getContentResolver().notifyChange(uri, null);
        }
        return numRows;
    }

}