code: public static long queryNumEntries(SQLiteDatabase db, String table, String selection,
              String[] selectionArgs) {
          String s = (!TextUtils.isEmpty(selection)) ? " where " + selection : "";
          return longForQuery(db, "select count(*) from " + table + s,
                      selectionArgs);
      }
docs: Query the table for the number of rows in the table.
  @param db the database the table is in
  @param table the name of the table to query
  @param selection A filter declaring which rows to return,
  formatted as an SQL WHERE clause (excluding the WHERE itself).
  Passing null will count all rows for the given table
  @param selectionArgs You may include ?s in selection,
  which will be replaced by the values from selectionArgs,
  in order that they appear in the selection.
  The values will be bound as Strings.
  @return the number of rows in the table filtered by the selection