public long save(UnitOfMeasure unitOfMeasure) {

    if (!unitExist(unitOfMeasure.getName())) {

      ContentValues values = new ContentValues();
      values.put(UnitsOfMeasureTable.COLUMN_ID, unitOfMeasure.getWeb_id());
      values.put(UnitsOfMeasureTable.COLUMN_WEB_ID, unitOfMeasure.getWeb_id());
      values.put(UnitsOfMeasureTable.COLUMN_NAME, unitOfMeasure.getName());
      return database.insert(UnitsOfMeasureTable.TABLE_NAME, null, values);

    } else {
      return update(unitOfMeasure);
    }
  }
  public long saveMultipleData(ArrayList<UnitOfMeasure> unitOfMeasures) {

    for (int i = 0; i < unitOfMeasures.size(); i++) {

      UnitOfMeasure unitOfMeasure = unitOfMeasures.get(i);

      if (!unitExist(unitOfMeasure.getName())) {
        ContentValues values = new ContentValues();
        values.put(UnitsOfMeasureTable.COLUMN_ID, unitOfMeasure.getWeb_id());
        values.put(UnitsOfMeasureTable.COLUMN_WEB_ID, unitOfMeasure.getWeb_id());
        values.put(UnitsOfMeasureTable.COLUMN_NAME, unitOfMeasure.getName());

        database.insert(UnitsOfMeasureTable.TABLE_NAME, null, values);
      } else {

        return update(unitOfMeasure);
      }
    }
    return 1;
  }
  public long update(UnitOfMeasure unitOfMeasure) {
    ContentValues values = new ContentValues();
    values.put(UnitsOfMeasureTable.COLUMN_NAME, unitOfMeasure.getName());

    long result =
        database.update(
            UnitsOfMeasureTable.TABLE_NAME,
            values,
            WHERE_WEB_ID_EQUALS,
            new String[] {String.valueOf(unitOfMeasure.getWeb_id())});
    Log.d("Update Result:", "=" + result);
    return result;
  }