code: public String buildQuery(
              String[] projectionIn, String selection, String groupBy,
              String having, String sortOrder, String limit) {
          String[] projection = computeProjection(projectionIn);
  
          StringBuilder where = new StringBuilder();
          boolean hasBaseWhereClause = mWhereClause != null && mWhereClause.length() > 0;
  
          if (hasBaseWhereClause) {
              where.append(mWhereClause.toString());
              where.append(')');
          }
  
          // Tack on the user's selection, if present.
          if (selection != null && selection.length() > 0) {
              if (hasBaseWhereClause) {
                  where.append(" AND ");
              }
  
              where.append('(');
              where.append(selection);
              where.append(')');
          }
  
          return buildQueryString(
                  mDistinct, mTables, projection, where.toString(),
                  groupBy, having, sortOrder, limit);
      }
docs: Construct a SELECT statement suitable for use in a group of
  SELECT statements that will be joined through UNION operators
  in buildUnionQuery.
  
  @param projectionIn A list of which columns to return. Passing
  null will return all columns, which is discouraged to
  prevent reading data from storage that isn't going to be
  used.
  @param selection A filter declaring which rows to return,
  formatted as an SQL WHERE clause (excluding the WHERE
  itself).  Passing null will return all rows for the given
  URL.
  @param groupBy A filter declaring how to group rows, formatted
  as an SQL GROUP BY clause (excluding the GROUP BY itself).
  Passing null will cause the rows to not be grouped.
  @param having A filter declare which row groups to include in
  the cursor, if row grouping is being used, formatted as an
  SQL HAVING clause (excluding the HAVING itself).  Passing
  null will cause all row groups to be included, and is
  required when row grouping is not being used.
  @param sortOrder How to order the rows, formatted as an SQL
  ORDER BY clause (excluding the ORDER BY itself). Passing null
  will use the default sort order, which may be unordered.
  @param limit Limits the number of rows returned by the query,
  formatted as LIMIT clause. Passing null denotes no LIMIT clause.
  @return the resulting SQL SELECT statement