示例#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;
 }