コード例 #1
0
ファイル: BaseDAO.java プロジェクト: Natinux/LocationLibrary
 /**
  * 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
ファイル: BaseDAO.java プロジェクト: Natinux/LocationLibrary
  protected Cursor getAllCursor(String orderConditions) {
    Cursor c = null;

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

    return c;
  }
コード例 #3
0
ファイル: BaseDAO.java プロジェクト: Natinux/LocationLibrary
  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
ファイル: BaseDAO.java プロジェクト: Natinux/LocationLibrary
 /**
  * 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;
 }