Open GoogleCodeExporter opened 8 years ago
at ActiveRecordBase.java append: private static final String[] countProjection = new String[]{"count(*)"}; /** * count table * @param <T> * @param type * @return * @throws ActiveRecordException */ public <T extends ActiveRecordBase> long count(Class<T> type,String where,String[] whereArgs) throws ActiveRecordException { if (m_Database == null) throw new ActiveRecordException("Set database first"); T entity; try { entity = type.newInstance(); } catch (IllegalAccessException e) { throw new ActiveRecordException(e.getLocalizedMessage()); } catch (InstantiationException e) { throw new ActiveRecordException(e.getLocalizedMessage()); } Cursor c = m_Database.query(entity.getTableName(), countProjection, where, whereArgs); try { c.moveToFirst(); return c.getLong(0); } finally { c.close(); } }
Original issue reported on code.google.com by wangchu...@gmail.com on 1 Dec 2010 at 4:52
wangchu...@gmail.com
Great addition. Will implement
Original comment by Vladimir.Kroz on 29 Mar 2011 at 8:38
Vladimir.Kroz
Original comment by Vladimir.Kroz on 29 Mar 2011 at 8:39
Original issue reported on code.google.com by
wangchu...@gmail.com
on 1 Dec 2010 at 4:52