SQLite学习七、更新DB数据库中BLOB字段值

在代码中直接用update 语句执行会报错,需要使用 ContentValues 传入参数,进行更新

    private void saveFile2LocalDB(String url) {
        SQLiteDatabase wyhcjgDb = WyhcJgDBManager.getInstance().getDbHelper().getWritableDatabase(Encryption.getInstance().invoke5());
        wyhcjgDb.beginTransaction();
        try {
            byte[] bytes = downloadFile(url);
            //需要更新本地数据库中附件的二进制流和下载状态
            assert bytes != null;
            String whereSql = " FJLJ = '" + url + "' and ARG4 isnull";
            ContentValues cv = new ContentValues();
            cv.put("ARG4", bytes);
            cv.put("IS_SELECTED", Wyhcfj.FJ_DOWNLOAD);
            wyhcjgDb.update(WyhcjgOpenHelper.WYHCFJ_TABLE, cv, whereSql, null);
            wyhcjgDb.setTransactionSuccessful();
        } catch (Exception e) {
            e.printStackTrace();
        }
        wyhcjgDb.endTransaction();
        //更新UI
        if (mHandler != null) {
            Message message = mHandler.obtainMessage(UPDATE_STATUS, url);
            message.arg1 = mPosition;
            mHandler.sendMessage(message);
        }
    }

你可能感兴趣的:(android,数据库,数据库,sqlite)