List of usage examples for android.database DatabaseUtils longForQuery
public static long longForQuery(SQLiteDatabase db, String query, String[] selectionArgs)
From source file:Main.java
public static int getRowCount(SQLiteDatabase db, boolean distinct, String table, String[] columns, String selection, String[] selectionArgs, String groupBy, String having, String orderBy, String limit) { if (columns != null && columns.length > 0) { columns = new String[] { columns[0] }; }/*from ww w . java 2 s . co m*/ String sql = SQLiteQueryBuilder.buildQueryString(distinct, table, columns, selection, groupBy, having, orderBy, limit); String countSelection = "SELECT count(*) FROM (" + sql + ")"; return (int) DatabaseUtils.longForQuery(db, countSelection, selectionArgs); }