在代码中直接用update 语句执行会报错,须要使用 ContentValues 传入参数,进行更新web
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); } }