/** * 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; }
protected Cursor getAllCursor(String orderConditions) { Cursor c = null; c = db.rawQuery( "select * from " + getTableName() + ' ' + StringUtils.safe(orderConditions), null); return c; }
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; }
/** * 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; }