示例#1
0
 @Override
 public int getSize() {
   SQLiteDatabase db = this.getReadableDatabase();
   int size =
       ((Long) ExtraUtils.longForQuery(db, "SELECT COUNT(*) FROM " + this.table_identifier, null))
           .intValue();
   db.close();
   return size;
 }
示例#2
0
 @Override
 public void insert(STPoint point) {
   SQLiteDatabase db = this.getWritableDatabase();
   ContentValues values = new ContentValues();
   values.put("minX", point.getX());
   values.put("maxX", point.getX());
   values.put("minY", point.getY());
   values.put("maxY", point.getY());
   values.put("minT", point.getT());
   values.put("maxT", point.getT());
   db.insert(
       this.table_identifier, // table
       null, // nullColumnHack
       values); // key/value -> keys = column names/ values = column values
   db.close();
 }
示例#3
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;
  }