private void updateCatagory() {

    final Dao<CatagoryModel, Integer> catagoryDoa;

    try {
      catagoryDoa = getHelper().getCatagoryDao();

      UpdateBuilder<CatagoryModel, Integer> updateBuilder = catagoryDoa.updateBuilder();
      updateBuilder.updateColumnValue("catagoryName", catagoryEditText.getText().toString());

      updateBuilder
          .where()
          .eq("categoryId", Integer.valueOf(catagoryModel.getCategoryId()))
          .and()
          .eq("catagoryName", catagoryModel.getCatagoryName());
      ;
      updateBuilder.update();

      Snackbar snackbar =
          Snackbar.make(view, "Catagory updated sucessfully!!", Snackbar.LENGTH_LONG);

      snackbar.show();

    } catch (SQLException e) {
      e.printStackTrace();
    }
  }
Пример #2
0
 @Override
 public void disableAllTriggered() {
   try {
     UpdateBuilder<Alarm, Integer> updateBuilder = getDao().updateBuilder();
     updateBuilder.updateColumnValue(Alarm.TRIGGERED, false).where().eq(Alarm.TRIGGERED, true);
     int count = updateBuilder.update();
     _logger.debug("Number of rows updated:[{}]", count);
   } catch (SQLException ex) {
     _logger.error("unable to update alarm triggered status", ex);
   }
 }
  public void updateNoteList(NoteLite noteLite) {
    try {
      UpdateBuilder<NoteLite, Integer> updateBuilder = getNoteLiteDataDao().updateBuilder();
      updateBuilder.where().eq(Constants.memberNotes_UserId, noteLite.getMemberId());
      updateBuilder.updateColumnValue(Constants.memberNotes_UserNote, noteLite.getUserNote());
      updateBuilder.update();

    } catch (SQLException e) {
      e.printStackTrace();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  public void update(final Dataset dataset, final Field field, final String data) {
    try {
      UpdateBuilder<Data, Integer> updateBuilder = getDataDao().updateBuilder();
      Where<Data, Integer> where = updateBuilder.where();
      where.eq("dataset_id", dataset);
      where.and();
      where.eq("field_id", field);

      updateBuilder.updateColumnValue("data" /* column */, data /* value */);
      updateBuilder.update();
    } catch (SQLException e) {
      e.printStackTrace();
    }
  }
Пример #5
0
  /* update */
  public static int update(
      DatabaseHelper databaseHelper,
      String columnvalue,
      String originalvalue,
      String column,
      String value) {
    RuntimeExceptionDao<system_messageVo, Integer> system_messageDao =
        databaseHelper.getSystem_messageDao();
    UpdateBuilder<system_messageVo, Integer> updateBuilder = system_messageDao.updateBuilder();
    try {
      // 判斷式 哪一欄 = 值
      updateBuilder.where().eq(columnvalue, originalvalue);
      // update the value of your field(s)
      updateBuilder.updateColumnValue(column, value);

      return updateBuilder.update();
    } catch (Exception e) {
      e.printStackTrace();
    }
    return 0;
  }
  public static void updateRowFromTable2(Context context, ObservationInstance sp) {
    Dao<ObservationInstance, Integer> dao;
    try {
      dao = DatabaseHelper.getInstance(context).getSaveParamsDao();
      UpdateBuilder<ObservationInstance, Integer> query = dao.updateBuilder();
      // query.updateColumnValue("group_id", sp.getGroupId());
      query.updateColumnValue("group", sp.getGroup());
      query.updateColumnValue("habitat_id", sp.getHabitatId());
      query.updateColumnValue("fromDate", sp.getFromDate());
      query.updateColumnValue("placeName", sp.getPlaceName());
      query.updateColumnValue("areas", sp.getAreas());
      query.updateColumnValue("maxVotedReco", sp.getMaxVotedReco());
      // query.updateColumnValue("recoName", sp.getRecoName());

      query.updateColumnValue("resource", sp.getResource());
      // query.updateColumnValue("image_type", sp.getImageType());
      query.updateColumnValue("status", sp.getStatus());
      query.updateColumnValue("message", sp.getMessage());
      query.updateColumnValue("notes", sp.getNotes());
      query.updateColumnValue("userGroupsList", sp.getUserGroupsList());
      if (sp.getId() == -1)
        query.where().eq("server_id", sp.getServer_id()).and().eq("id", sp.getId());
      else query.where().eq("id", sp.getId());
      int count = query.update();
      Log.d("ObservationParamTable", "Updated " + count + " orders");
    } catch (Exception e) {
      e.printStackTrace();
    }
  }