Пример #1
0
 /**
  * Find all by field.
  *
  * @param fieldName - field name to search by
  * @param value - the value of the field
  * @param orderConditions - the "order by" sentence. May be <b>null</b>.
  * @return the list
  */
 public List<T> findAllByField(String fieldName, String value, String orderConditions) {
   Cursor c = null;
   List<T> result = null;
   try {
     c =
         db.rawQuery(
             "select * from "
                 + getTableName()
                 + " where "
                 + fieldName
                 + " = ? "
                 + StringUtils.safe(orderConditions),
             new String[] {value});
     result = new ArrayList<T>();
     if (c.moveToFirst()) {
       do {
         result.add(fromCursor(c));
       } while (c.moveToNext());
     }
   } finally {
     if (c != null) {
       c.close();
     }
   }
   return result;
 }
Пример #2
0
  protected Cursor getAllCursor(String orderConditions) {
    Cursor c = null;

    c =
        db.rawQuery(
            "select * from " + getTableName() + ' ' + StringUtils.safe(orderConditions), null);

    return c;
  }
Пример #3
0
  public Cursor getCursorByField(String fieldName, String value, String orderConditions) {
    Cursor c = null;

    c =
        db.rawQuery(
            "select * from "
                + getTableName()
                + " where "
                + fieldName
                + " = ? "
                + StringUtils.safe(orderConditions),
            new String[] {value});

    return c;
  }
Пример #4
0
 /**
  * Find all.
  *
  * @param orderConditions the order conditions
  * @return the list
  */
 protected List<T> findAll(String orderConditions) {
   Cursor c = null;
   List<T> result = null;
   try {
     c =
         db.rawQuery(
             "select * from " + getTableName() + ' ' + StringUtils.safe(orderConditions), null);
     result = new ArrayList<T>();
     if (c.moveToFirst()) {
       do {
         result.add(fromCursor(c));
       } while (c.moveToNext());
     }
   } finally {
     if (c != null) {
       c.close();
     }
   }
   return result;
 }