Пример #1
0
  /**
   * Load a FillUp based on its ID.
   *
   * @param calculator The CalculationEngine to use when doing calculations.
   * @param id The ID of the FillUp in the database.
   */
  public FillUp(CalculationEngine calculator, long id) {
    this(calculator);
    String selection = _ID + " = ?";
    String[] selectionArgs = new String[] {String.valueOf(id)};
    String groupBy = null;
    String having = null;
    String orderBy = null;

    String[] projection = getProjection();

    openDatabase();

    Cursor c =
        m_db.query(
            FillUpsProvider.FILLUPS_TABLE_NAME,
            projection,
            selection,
            selectionArgs,
            groupBy,
            having,
            orderBy);

    if (c.getCount() == 1) {
      m_id = id;
      c.moveToFirst();
      load(c);
    }
    closeDatabase(c);
  }
Пример #2
0
  /**
   * Create a new FillUp and have it initialize itself from the specified database Cursor. Note that
   * this should never change the cursor (it won't move the cursor to the next row or anything), so
   * the caller needs to be aware of that.
   *
   * @param calculator The CalculationEngine to use when doing calculations
   * @param c The cursor to use to get the FillUp's information
   */
  public FillUp(CalculationEngine calculator, Cursor c) {
    this(calculator);

    load(c);
  }