Beispiel #1
0
  public ArrayList<Vaccine> getPreviousVaccine(int pID) {
    ArrayList<Vaccine> vaccineArrayList = new ArrayList<>();
    long currentTime = Calendar.getInstance().getTime().getTime();
    openDB();
    Cursor cursor =
        db.query(
            DBConstants.VACCINE_TABLE,
            null,
            DBConstants.PROFILE_ID + "=" + pID + " AND " + DBConstants.DATE + "<=" + currentTime,
            null,
            null,
            null,
            DBConstants.DATE + " DESC");
    if (cursor != null && cursor.getCount() > 0) {
      cursor.moveToFirst();
      do {
        Vaccine vaccine = new Vaccine();
        vaccine.setId(cursor.getInt(cursor.getColumnIndex(DBConstants.ID)));
        vaccine.setVaccine(cursor.getString(cursor.getColumnIndex(DBConstants.VACCINE)));

        Long date = Long.parseLong(cursor.getString(cursor.getColumnIndex(DBConstants.DATE)));
        Calendar c = Calendar.getInstance();
        c.setTimeInMillis(date);
        vaccine.setDateTime(c);

        vaccine.setRemind(
            Helper.getBool(cursor.getInt(cursor.getColumnIndex(DBConstants.REMINDER))));
        vaccineArrayList.add(vaccine);
      } while (cursor.moveToNext());
    }
    clodeDB();
    return vaccineArrayList;
  }
Beispiel #2
0
  public Vaccine getVaccine(int id) {
    openDB();
    Cursor cursor =
        db.query(
            DBConstants.VACCINE_TABLE,
            null,
            DBConstants.ID + "=" + id,
            null,
            null,
            null,
            DBConstants.DATE + " DESC");
    if (cursor != null && cursor.getCount() > 0) {
      cursor.moveToFirst();
      Vaccine vaccine = new Vaccine();
      vaccine.setId(cursor.getInt(cursor.getColumnIndex(DBConstants.ID)));
      vaccine.setVaccine(cursor.getString(cursor.getColumnIndex(DBConstants.VACCINE)));

      Long date = Long.parseLong(cursor.getString(cursor.getColumnIndex(DBConstants.DATE)));
      Calendar c = Calendar.getInstance();
      c.setTimeInMillis(date);
      vaccine.setDateTime(c);
      vaccine.setProfileID(cursor.getInt(cursor.getColumnIndex(DBConstants.PROFILE_ID)));
      vaccine.setRemind(Helper.getBool(cursor.getInt(cursor.getColumnIndex(DBConstants.REMINDER))));
      vaccine.setEventID(cursor.getInt(cursor.getColumnIndex(DBConstants.EVENT_ID)));
      clodeDB();
      return vaccine;
    }
    clodeDB();
    return null;
  }