Beispiel #1
0
 private float getRowValueHelper(SQLiteDatabase db, String query, int index) {
   Cursor cur = db.rawQuery(query, null);
   cur.moveToFirst();
   float val = cur.getFloat(index);
   cur.close();
   return val;
 }
Beispiel #2
0
  @Override
  public List<STPoint> range(STRegion range) {
    SQLiteDatabase db = this.getReadableDatabase();

    String query = "SELECT id,minX,maxX,minY,maxY,minT,maxT from " + this.table_identifier + " ";

    STPoint mins = range.getMins();
    STPoint maxs = range.getMaxs();

    String prefix = " WHERE ";
    if (mins.hasX() && maxs.hasX()) {
      query +=
          prefix
              + " minX >= "
              + String.valueOf(mins.getX())
              + " AND maxX <= "
              + String.valueOf(maxs.getX());
      prefix = " AND ";
    }

    if (mins.hasY() && maxs.hasY()) {
      query +=
          prefix
              + " minY >= "
              + String.valueOf(mins.getY())
              + " AND maxY <= "
              + String.valueOf(maxs.getY());
      prefix = " AND ";
    }

    if (mins.hasT() && maxs.hasT()) {
      query +=
          prefix
              + " minT >= "
              + String.valueOf(mins.getT())
              + " AND maxT <= "
              + String.valueOf(maxs.getT());
      prefix = " AND ";
    }

    Cursor cur = db.rawQuery(query, null);

    List<STPoint> points = cursorToList(cur);
    db.close();
    return points;
  }