Exemplo n.º 1
0
  public Crime getCrime(UUID uuid) {
    /*for (Crime crime : mCrimes) {
        if (crime.getId().equals(uuid)) {
            return crime;
        }
    }*/

    CrimeCursorWrapper cursorWrapper =
        queryCrimes(CrimeTable.Cols.UUID + " = ?", new String[] {uuid.toString()});

    try {
      if (cursorWrapper.getCount() == 0) {
        return null;
      }

      cursorWrapper.moveToFirst();

      return cursorWrapper.getCrime();
    } finally {
      cursorWrapper.close();
    }
  }
Exemplo n.º 2
0
  public List<Crime> getCrimes() {
    //        return mCrimes;
    List<Crime> crimes = new ArrayList<>();

    CrimeCursorWrapper cursorWrapper = queryCrimes(null, null);

    try {
      cursorWrapper.moveToFirst();
      while (!cursorWrapper.isAfterLast()) {
        crimes.add(cursorWrapper.getCrime());
        cursorWrapper.moveToNext();
      }
    } finally {
      cursorWrapper.close();
    }

    return crimes;
  }