Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#pubctors) \| [Methods](https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#inhmethods)

# SQLiteQueryBuilder

*** ** * ** ***


`
public


class
SQLiteQueryBuilder
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.database.sqlite.SQLiteQueryBuilder |

<br />

*** ** * ** ***

This is a convenience class that helps build SQL queries to be sent to
`https://developer.android.com/reference/android/database/sqlite/SQLiteDatabase` objects.


This class is often used to compose a SQL query from client-supplied fragments. Best practice
to protect against invalid or illegal SQL is to set the following:

- `https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#setStrict(boolean)` true.
- `https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#setProjectionMap(java.util.Map<java.lang.String,java.lang.String>)` with the list of queryable columns.
- `https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#setStrictColumns(boolean)` true.
- `https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#setStrictGrammar(boolean)` true.

<br />

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#SQLiteQueryBuilder()() ` |

| ### Public methods ||
|---|---|
| ` static void` | ` https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#appendColumns(java.lang.StringBuilder,%20java.lang.String[])(https://developer.android.com/reference/java/lang/StringBuilder s, https://developer.android.com/reference/java/lang/String columns) ` Add the names that are non-null in columns to s, separating them with commas. |
| ` void` | ` https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#appendWhere(java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence inWhere) ` Append a chunk to the `WHERE` clause of the query. |
| ` void` | ` https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#appendWhereEscapeString(java.lang.String)(https://developer.android.com/reference/java/lang/String inWhere) ` Append a chunk to the `WHERE` clause of the query. |
| ` void` | ` https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#appendWhereStandalone(java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence inWhere) ` Add a standalone chunk to the `WHERE` clause of this query. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#buildQuery(java.lang.String[],%20java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String)(https://developer.android.com/reference/java/lang/String projectionIn, https://developer.android.com/reference/java/lang/String selection, https://developer.android.com/reference/java/lang/String groupBy, https://developer.android.com/reference/java/lang/String having, https://developer.android.com/reference/java/lang/String sortOrder, https://developer.android.com/reference/java/lang/String limit) ` Construct a `SELECT` statement suitable for use in a group of `SELECT` statements that will be joined through `UNION` operators in buildUnionQuery. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#buildQuery(java.lang.String[],%20java.lang.String,%20java.lang.String[],%20java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String)(https://developer.android.com/reference/java/lang/String projectionIn, https://developer.android.com/reference/java/lang/String selection, https://developer.android.com/reference/java/lang/String selectionArgs, https://developer.android.com/reference/java/lang/String groupBy, https://developer.android.com/reference/java/lang/String having, https://developer.android.com/reference/java/lang/String sortOrder, https://developer.android.com/reference/java/lang/String limit) ` *This method was deprecated in API level 15. This method's signature is misleading since no SQL parameter substitution is carried out. The selection arguments parameter does not get used at all. To avoid confusion, call `https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#buildQuery(java.lang.String[],%20java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String)` instead.* |
| ` static https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#buildQueryString(boolean,%20java.lang.String,%20java.lang.String[],%20java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String)(boolean distinct, https://developer.android.com/reference/java/lang/String tables, https://developer.android.com/reference/java/lang/String columns, https://developer.android.com/reference/java/lang/String where, https://developer.android.com/reference/java/lang/String groupBy, https://developer.android.com/reference/java/lang/String having, https://developer.android.com/reference/java/lang/String orderBy, https://developer.android.com/reference/java/lang/String limit) ` Build an SQL query string from the given clauses. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#buildUnionQuery(java.lang.String[],%20java.lang.String,%20java.lang.String)(https://developer.android.com/reference/java/lang/String subQueries, https://developer.android.com/reference/java/lang/String sortOrder, https://developer.android.com/reference/java/lang/String limit) ` Given a set of subqueries, all of which are `SELECT` statements, construct a query that returns the union of what those subqueries return. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#buildUnionSubQuery(java.lang.String,%20java.lang.String[],%20java.util.Set<java.lang.String>,%20int,%20java.lang.String,%20java.lang.String,%20java.lang.String[],%20java.lang.String,%20java.lang.String)(https://developer.android.com/reference/java/lang/String typeDiscriminatorColumn, https://developer.android.com/reference/java/lang/String unionColumns, https://developer.android.com/reference/java/util/Set<https://developer.android.com/reference/java/lang/String> columnsPresentInTable, int computedColumnsOffset, https://developer.android.com/reference/java/lang/String typeDiscriminatorValue, https://developer.android.com/reference/java/lang/String selection, https://developer.android.com/reference/java/lang/String selectionArgs, https://developer.android.com/reference/java/lang/String groupBy, https://developer.android.com/reference/java/lang/String having) ` *This method was deprecated in API level 15. This method's signature is misleading since no SQL parameter substitution is carried out. The selection arguments parameter does not get used at all. To avoid confusion, call `https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#buildUnionSubQuery(java.lang.String,%20java.lang.String[],%20java.util.Set<java.lang.String>,%20int,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String)` instead.* |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#buildUnionSubQuery(java.lang.String,%20java.lang.String[],%20java.util.Set<java.lang.String>,%20int,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String)(https://developer.android.com/reference/java/lang/String typeDiscriminatorColumn, https://developer.android.com/reference/java/lang/String unionColumns, https://developer.android.com/reference/java/util/Set<https://developer.android.com/reference/java/lang/String> columnsPresentInTable, int computedColumnsOffset, https://developer.android.com/reference/java/lang/String typeDiscriminatorValue, https://developer.android.com/reference/java/lang/String selection, https://developer.android.com/reference/java/lang/String groupBy, https://developer.android.com/reference/java/lang/String having) ` Construct a `SELECT` statement suitable for use in a group of `SELECT` statements that will be joined through `UNION` operators in buildUnionQuery. |
| ` int` | ` https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#delete(android.database.sqlite.SQLiteDatabase,%20java.lang.String,%20java.lang.String[])(https://developer.android.com/reference/android/database/sqlite/SQLiteDatabase db, https://developer.android.com/reference/java/lang/String selection, https://developer.android.com/reference/java/lang/String selectionArgs) ` Perform a delete by combining all current settings and the information passed into this method. |
| ` https://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.CursorFactory` | ` https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#getCursorFactory()() ` Gets the cursor factory to be used for the query, as last configured by `https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#setCursorFactory(android.database.sqlite.SQLiteDatabase.CursorFactory)`. |
| ` https://developer.android.com/reference/java/util/Collection<https://developer.android.com/reference/java/util/regex/Pattern>` | ` https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#getProjectionGreylist()() ` Gets the projection greylist for the query, as last configured by `https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#setProjectionGreylist(java.util.Collection<java.util.regex.Pattern>)`. |
| ` https://developer.android.com/reference/java/util/Map<https://developer.android.com/reference/java/lang/String, https://developer.android.com/reference/java/lang/String>` | ` https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#getProjectionMap()() ` Gets the projection map for the query, as last configured by `https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#setProjectionMap(java.util.Map<java.lang.String,java.lang.String>)`. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#getTables()() ` Returns the list of tables being queried |
| ` long` | ` https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#insert(android.database.sqlite.SQLiteDatabase,%20android.content.ContentValues)(https://developer.android.com/reference/android/database/sqlite/SQLiteDatabase db, https://developer.android.com/reference/android/content/ContentValues values) ` Perform an insert by combining all current settings and the information passed into this method. |
| ` boolean` | ` https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#isDistinct()() ` Get if the query is marked as `DISTINCT`, as last configured by `https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#setDistinct(boolean)`. |
| ` boolean` | ` https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#isStrict()() ` Get if the query is marked as strict, as last configured by `https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#setStrict(boolean)`. |
| ` boolean` | ` https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#isStrictColumns()() ` Get if the query is marked as strict, as last configured by `https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#setStrictColumns(boolean)`. |
| ` boolean` | ` https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#isStrictGrammar()() ` Get if the query is marked as strict, as last configured by `https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#setStrictGrammar(boolean)`. |
| ` https://developer.android.com/reference/android/database/Cursor` | ` https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#query(android.database.sqlite.SQLiteDatabase,%20java.lang.String[],%20java.lang.String,%20java.lang.String[],%20java.lang.String,%20java.lang.String,%20java.lang.String)(https://developer.android.com/reference/android/database/sqlite/SQLiteDatabase db, https://developer.android.com/reference/java/lang/String projectionIn, https://developer.android.com/reference/java/lang/String selection, https://developer.android.com/reference/java/lang/String selectionArgs, https://developer.android.com/reference/java/lang/String groupBy, https://developer.android.com/reference/java/lang/String having, https://developer.android.com/reference/java/lang/String sortOrder) ` Perform a query by combining all current settings and the information passed into this method. |
| ` https://developer.android.com/reference/android/database/Cursor` | ` https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#query(android.database.sqlite.SQLiteDatabase,%20java.lang.String[],%20java.lang.String,%20java.lang.String[],%20java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String)(https://developer.android.com/reference/android/database/sqlite/SQLiteDatabase db, https://developer.android.com/reference/java/lang/String projectionIn, https://developer.android.com/reference/java/lang/String selection, https://developer.android.com/reference/java/lang/String selectionArgs, https://developer.android.com/reference/java/lang/String groupBy, https://developer.android.com/reference/java/lang/String having, https://developer.android.com/reference/java/lang/String sortOrder, https://developer.android.com/reference/java/lang/String limit) ` Perform a query by combining all current settings and the information passed into this method. |
| ` https://developer.android.com/reference/android/database/Cursor` | ` https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#query(android.database.sqlite.SQLiteDatabase,%20java.lang.String[],%20java.lang.String,%20java.lang.String[],%20java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20android.os.CancellationSignal)(https://developer.android.com/reference/android/database/sqlite/SQLiteDatabase db, https://developer.android.com/reference/java/lang/String projectionIn, https://developer.android.com/reference/java/lang/String selection, https://developer.android.com/reference/java/lang/String selectionArgs, https://developer.android.com/reference/java/lang/String groupBy, https://developer.android.com/reference/java/lang/String having, https://developer.android.com/reference/java/lang/String sortOrder, https://developer.android.com/reference/java/lang/String limit, https://developer.android.com/reference/android/os/CancellationSignal cancellationSignal) ` Perform a query by combining all current settings and the information passed into this method. |
| ` void` | ` https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#setCursorFactory(android.database.sqlite.SQLiteDatabase.CursorFactory)(https://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.CursorFactory factory) ` Sets the cursor factory to be used for the query. |
| ` void` | ` https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#setDistinct(boolean)(boolean distinct) ` Mark the query as `DISTINCT`. |
| ` void` | ` https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#setProjectionGreylist(java.util.Collection<java.util.regex.Pattern>)(https://developer.android.com/reference/java/util/Collection<https://developer.android.com/reference/java/util/regex/Pattern> projectionGreylist) ` Sets a projection greylist of columns that will be allowed through, even when `https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#setStrict(boolean)` is enabled. |
| ` void` | ` https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#setProjectionMap(java.util.Map<java.lang.String,java.lang.String>)(https://developer.android.com/reference/java/util/Map<https://developer.android.com/reference/java/lang/String, https://developer.android.com/reference/java/lang/String> columnMap) ` Sets the projection map for the query. |
| ` void` | ` https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#setStrict(boolean)(boolean strict) ` When set, the selection is verified against malicious arguments. |
| ` void` | ` https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#setStrictColumns(boolean)(boolean strictColumns) ` When enabled, verify that all projections and `https://developer.android.com/reference/android/content/ContentValues` only contain valid columns as defined by `https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#setProjectionMap(java.util.Map<java.lang.String,java.lang.String>)`. |
| ` void` | ` https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#setStrictGrammar(boolean)(boolean strictGrammar) ` When enabled, verify that all untrusted SQL conforms to a restricted SQL grammar. |
| ` void` | ` https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#setTables(java.lang.String)(https://developer.android.com/reference/java/lang/String inTables) ` Sets the list of tables to query. |
| ` int` | ` https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#update(android.database.sqlite.SQLiteDatabase,%20android.content.ContentValues,%20java.lang.String,%20java.lang.String[])(https://developer.android.com/reference/android/database/sqlite/SQLiteDatabase db, https://developer.android.com/reference/android/content/ContentValues values, https://developer.android.com/reference/java/lang/String selection, https://developer.android.com/reference/java/lang/String selectionArgs) ` Perform an update by combining all current settings and the information passed into this method. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||

## Public constructors

### SQLiteQueryBuilder

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public SQLiteQueryBuilder ()
```

<br />

<br />

## Public methods

### appendColumns

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void appendColumns (StringBuilder s, 
                String[] columns)
```

Add the names that are non-null in columns to s, separating
them with commas.

<br />

| Parameters ||
|---|---|
| `s` | `StringBuilder` <br /> |
| `columns` | `String` <br /> |

### appendWhere

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void appendWhere (CharSequence inWhere)
```

Append a chunk to the `WHERE` clause of the query. All chunks appended are surrounded
by parenthesis and `AND`ed with the selection passed to `https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#query(android.database.sqlite.SQLiteDatabase,%20java.lang.String[],%20java.lang.String,%20java.lang.String[],%20java.lang.String,%20java.lang.String,%20java.lang.String)`. The final
`WHERE` clause looks like:


WHERE (\<append chunk 1\>\<append chunk2\>) AND (\<query() selection parameter\>)

<br />

| Parameters ||
|---|---|
| `inWhere` | `CharSequence`: the chunk of text to append to the `WHERE` clause. This value cannot be `null`. <br /> |

### appendWhereEscapeString

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void appendWhereEscapeString (String inWhere)
```

Append a chunk to the `WHERE` clause of the query. All chunks appended are surrounded
by parenthesis and ANDed with the selection passed to `https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#query(android.database.sqlite.SQLiteDatabase,%20java.lang.String[],%20java.lang.String,%20java.lang.String[],%20java.lang.String,%20java.lang.String,%20java.lang.String)`. The final
`WHERE` clause looks like:


WHERE (\<append chunk 1\>\<append chunk2\>) AND (\<query() selection parameter\>)

<br />

| Parameters ||
|---|---|
| `inWhere` | `String`: the chunk of text to append to the `WHERE` clause. it will be escaped to avoid SQL injection attacks. This value cannot be `null`. <br /> |

### appendWhereStandalone

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void appendWhereStandalone (CharSequence inWhere)
```

Add a standalone chunk to the `WHERE` clause of this query.


This method differs from `https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#appendWhere(java.lang.CharSequence)` in that it
automatically appends `AND` to any existing `WHERE` clause
already under construction before appending the given standalone
expression wrapped in parentheses.

<br />

| Parameters ||
|---|---|
| `inWhere` | `CharSequence`: the standalone expression to append to the `WHERE` clause. It will be wrapped in parentheses when it's appended. This value cannot be `null`. <br /> |

### buildQuery

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String buildQuery (String[] projectionIn, 
                String selection, 
                String groupBy, 
                String having, 
                String sortOrder, 
                String limit)
```

Construct a `SELECT` statement suitable for use in a group of
`SELECT` statements that will be joined through `UNION` operators
in buildUnionQuery.

<br />

| Parameters ||
|---|---|
| `projectionIn` | `String`: 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. <br /> |
| `selection` | `String`: 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. <br /> |
| `groupBy` | `String`: 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. <br /> |
| `having` | `String`: 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. <br /> |
| `sortOrder` | `String`: 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. <br /> |
| `limit` | `String`: Limits the number of rows returned by the query, formatted as `LIMIT` clause. Passing null denotes no `LIMIT` clause. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the resulting SQL `SELECT` statement <br /> |

### buildQuery

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
15](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String buildQuery (String[] projectionIn, 
                String selection, 
                String[] selectionArgs, 
                String groupBy, 
                String having, 
                String sortOrder, 
                String limit)
```


**This method was deprecated
in API level 15.**   

This method's signature is misleading since no SQL parameter
substitution is carried out. The selection arguments parameter does not get
used at all. To avoid confusion, call
`https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#buildQuery(java.lang.String[],%20java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String)` instead.

<br />

<br />

| Parameters ||
|---|---|
| `projectionIn` | `String` <br /> |
| `selection` | `String` <br /> |
| `selectionArgs` | `String` <br /> |
| `groupBy` | `String` <br /> |
| `having` | `String` <br /> |
| `sortOrder` | `String` <br /> |
| `limit` | `String` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | <br /> |

### buildQueryString

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static String buildQueryString (boolean distinct, 
                String tables, 
                String[] columns, 
                String where, 
                String groupBy, 
                String having, 
                String orderBy, 
                String limit)
```

Build an SQL query string from the given clauses.

<br />

| Parameters ||
|---|---|
| `distinct` | `boolean`: true if you want each row to be unique, false otherwise. <br /> |
| `tables` | `String`: The table names to compile the query against. <br /> |
| `columns` | `String`: 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. <br /> |
| `where` | `String`: 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. <br /> |
| `groupBy` | `String`: 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. <br /> |
| `having` | `String`: 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. <br /> |
| `orderBy` | `String`: 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. <br /> |
| `limit` | `String`: Limits the number of rows returned by the query, formatted as `LIMIT` clause. Passing null denotes no `LIMIT` clause. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the SQL query string <br /> |

### buildUnionQuery

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String buildUnionQuery (String[] subQueries, 
                String sortOrder, 
                String limit)
```

Given a set of subqueries, all of which are `SELECT` statements,
construct a query that returns the union of what those
subqueries return.

<br />

| Parameters ||
|---|---|
| `subQueries` | `String`: an array of SQL `SELECT` statements, all of which must have the same columns as the same positions in their results <br /> |
| `sortOrder` | `String`: 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. <br /> |
| `limit` | `String`: The limit clause, which applies to the entire union result set <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the resulting SQL `SELECT` statement <br /> |

### buildUnionSubQuery

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
15](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String buildUnionSubQuery (String typeDiscriminatorColumn, 
                String[] unionColumns, 
                Set<String> columnsPresentInTable, 
                int computedColumnsOffset, 
                String typeDiscriminatorValue, 
                String selection, 
                String[] selectionArgs, 
                String groupBy, 
                String having)
```


**This method was deprecated
in API level 15.**   

This method's signature is misleading since no SQL parameter
substitution is carried out. The selection arguments parameter does not get
used at all. To avoid confusion, call
`https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#buildUnionSubQuery(java.lang.String,%20java.lang.String[],%20java.util.Set<java.lang.String>,%20int,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String)`
instead.

<br />

<br />

| Parameters ||
|---|---|
| `typeDiscriminatorColumn` | `String` <br /> |
| `unionColumns` | `String` <br /> |
| `columnsPresentInTable` | `Set` <br /> |
| `computedColumnsOffset` | `int` <br /> |
| `typeDiscriminatorValue` | `String` <br /> |
| `selection` | `String` <br /> |
| `selectionArgs` | `String` <br /> |
| `groupBy` | `String` <br /> |
| `having` | `String` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | <br /> |

### buildUnionSubQuery

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String buildUnionSubQuery (String typeDiscriminatorColumn, 
                String[] unionColumns, 
                Set<String> columnsPresentInTable, 
                int computedColumnsOffset, 
                String typeDiscriminatorValue, 
                String selection, 
                String groupBy, 
                String having)
```

Construct a `SELECT` statement suitable for use in a group of
`SELECT` statements that will be joined through `UNION` operators
in buildUnionQuery.

<br />

| Parameters ||
|---|---|
| `typeDiscriminatorColumn` | `String`: the name of the result column whose cells will contain the name of the table from which each row was drawn. <br /> |
| `unionColumns` | `String`: the names of the columns to appear in the result. This may include columns that do not appear in the table this `SELECT` is querying (i.e. mTables), but that do appear in one of the other tables in the `UNION` query that we are constructing. <br /> |
| `columnsPresentInTable` | `Set`: a Set of the names of the columns that appear in this table (i.e. in the table whose name is mTables). Since columns in unionColumns include columns that appear only in other tables, we use this array to distinguish which ones actually are present. Other columns will have NULL values for results from this subquery. <br /> |
| `computedColumnsOffset` | `int`: all columns in unionColumns before this index are included under the assumption that they're computed and therefore won't appear in columnsPresentInTable, e.g. "date \* 1000 as normalized_date" <br /> |
| `typeDiscriminatorValue` | `String`: the value used for the type-discriminator column in this subquery <br /> |
| `selection` | `String`: 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. <br /> |
| `groupBy` | `String`: 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. <br /> |
| `having` | `String`: 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. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the resulting SQL `SELECT` statement <br /> |

### delete

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int delete (SQLiteDatabase db, 
                String selection, 
                String[] selectionArgs)
```

Perform a delete by combining all current settings and the
information passed into this method.

<br />

| Parameters ||
|---|---|
| `db` | `SQLiteDatabase`: the database to delete on. This value cannot be `null`. <br /> |
| `selection` | `String`: 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. <br /> |
| `selectionArgs` | `String`: 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. This value may be `null`. <br /> |

| Returns ||
|---|---|
| `int` | the number of rows deleted <br /> |

### getCursorFactory

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public SQLiteDatabase.CursorFactory getCursorFactory ()
```

Gets the cursor factory to be used for the query, as last configured by
`https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#setCursorFactory(android.database.sqlite.SQLiteDatabase.CursorFactory)`.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.CursorFactory` | This value may be `null`. <br /> |

### getProjectionGreylist

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Collection<Pattern> getProjectionGreylist ()
```

Gets the projection greylist for the query, as last configured by
`https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#setProjectionGreylist(java.util.Collection<java.util.regex.Pattern>)`.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/Collection<https://developer.android.com/reference/java/util/regex/Pattern>` | This value may be `null`. <br /> |

### getProjectionMap

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Map<String, String> getProjectionMap ()
```

Gets the projection map for the query, as last configured by
`https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#setProjectionMap(java.util.Map<java.lang.String,java.lang.String>)`.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/Map<https://developer.android.com/reference/java/lang/String, https://developer.android.com/reference/java/lang/String>` | This value may be `null`. <br /> |

### getTables

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String getTables ()
```

Returns the list of tables being queried

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the list of tables being queried. This value may be `null`. <br /> |

### insert

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public long insert (SQLiteDatabase db, 
                ContentValues values)
```

Perform an insert by combining all current settings and the
information passed into this method.

<br />

| Parameters ||
|---|---|
| `db` | `SQLiteDatabase`: the database to insert on. This value cannot be `null`. <br /> |
| `values` | `ContentValues`: This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `long` | the row ID of the newly inserted row, or -1 if an error occurred <br /> |

### isDistinct

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isDistinct ()
```

Get if the query is marked as `DISTINCT`, as last configured by
`https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#setDistinct(boolean)`.

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

### isStrict

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isStrict ()
```

Get if the query is marked as strict, as last configured by
`https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#setStrict(boolean)`.

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

### isStrictColumns

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isStrictColumns ()
```

Get if the query is marked as strict, as last configured by
`https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#setStrictColumns(boolean)`.

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

### isStrictGrammar

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isStrictGrammar ()
```

Get if the query is marked as strict, as last configured by
`https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#setStrictGrammar(boolean)`.

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

### query

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Cursor query (SQLiteDatabase db, 
                String[] projectionIn, 
                String selection, 
                String[] selectionArgs, 
                String groupBy, 
                String having, 
                String sortOrder)
```

Perform a query by combining all current settings and the
information passed into this method.

<br />

| Parameters ||
|---|---|
| `db` | `SQLiteDatabase`: the database to query on <br /> |
| `projectionIn` | `String`: 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. <br /> |
| `selection` | `String`: 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. <br /> |
| `selectionArgs` | `String`: 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. <br /> |
| `groupBy` | `String`: 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. <br /> |
| `having` | `String`: 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. <br /> |
| `sortOrder` | `String`: 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. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/database/Cursor` | a cursor over the result set <br /> |

**See also:**

- `https://developer.android.com/reference/android/content/ContentResolver#query(android.net.Uri,%20java.lang.String[],%20java.lang.String,%20java.lang.String[],%20java.lang.String)`

### query

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Cursor query (SQLiteDatabase db, 
                String[] projectionIn, 
                String selection, 
                String[] selectionArgs, 
                String groupBy, 
                String having, 
                String sortOrder, 
                String limit)
```

Perform a query by combining all current settings and the
information passed into this method.

<br />

| Parameters ||
|---|---|
| `db` | `SQLiteDatabase`: the database to query on <br /> |
| `projectionIn` | `String`: 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. <br /> |
| `selection` | `String`: 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. <br /> |
| `selectionArgs` | `String`: 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. <br /> |
| `groupBy` | `String`: 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. <br /> |
| `having` | `String`: 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. <br /> |
| `sortOrder` | `String`: 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. <br /> |
| `limit` | `String`: Limits the number of rows returned by the query, formatted as `LIMIT` clause. Passing null denotes no `LIMIT` clause. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/database/Cursor` | a cursor over the result set <br /> |

**See also:**

- `https://developer.android.com/reference/android/content/ContentResolver#query(android.net.Uri,%20java.lang.String[],%20java.lang.String,%20java.lang.String[],%20java.lang.String)`

### query

Added in [API level 16](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Cursor query (SQLiteDatabase db, 
                String[] projectionIn, 
                String selection, 
                String[] selectionArgs, 
                String groupBy, 
                String having, 
                String sortOrder, 
                String limit, 
                CancellationSignal cancellationSignal)
```

Perform a query by combining all current settings and the
information passed into this method.

<br />

| Parameters ||
|---|---|
| `db` | `SQLiteDatabase`: the database to query on <br /> |
| `projectionIn` | `String`: 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. <br /> |
| `selection` | `String`: 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. <br /> |
| `selectionArgs` | `String`: 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. <br /> |
| `groupBy` | `String`: 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. <br /> |
| `having` | `String`: 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. <br /> |
| `sortOrder` | `String`: 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. <br /> |
| `limit` | `String`: Limits the number of rows returned by the query, formatted as `LIMIT` clause. Passing null denotes no `LIMIT` clause. <br /> |
| `cancellationSignal` | `CancellationSignal`: A signal to cancel the operation in progress, or null if none. If the operation is canceled, then `https://developer.android.com/reference/android/os/OperationCanceledException` will be thrown when the query is executed. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/database/Cursor` | a cursor over the result set <br /> |

**See also:**

- `https://developer.android.com/reference/android/content/ContentResolver#query(android.net.Uri,%20java.lang.String[],%20java.lang.String,%20java.lang.String[],%20java.lang.String)`

### setCursorFactory

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setCursorFactory (SQLiteDatabase.CursorFactory factory)
```

Sets the cursor factory to be used for the query. You can use
one factory for all queries on a database but it is normally
easier to specify the factory when doing this query.

<br />

| Parameters ||
|---|---|
| `factory` | `SQLiteDatabase.CursorFactory`: the factory to use. This value may be `null`. <br /> |

### setDistinct

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setDistinct (boolean distinct)
```

Mark the query as `DISTINCT`.

<br />

| Parameters ||
|---|---|
| `distinct` | `boolean`: if true the query is `DISTINCT`, otherwise it isn't <br /> |

### setProjectionGreylist

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setProjectionGreylist (Collection<Pattern> projectionGreylist)
```

Sets a projection greylist of columns that will be allowed through, even
when `https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#setStrict(boolean)` is enabled. This provides a way for
abusive custom columns like `COUNT(*)` to continue working.

<br />

| Parameters ||
|---|---|
| `projectionGreylist` | `Collection`: This value may be `null`. <br /> |

### setProjectionMap

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setProjectionMap (Map<String, String> columnMap)
```

Sets the projection map for the query. The projection map maps
from column names that the caller passes into query to database
column names. This is useful for renaming columns as well as
disambiguating column names when doing joins. For example you
could map "name" to "people.name". If a projection map is set
it must contain all column names the user may request, even if
the key and value are the same.

<br />

| Parameters ||
|---|---|
| `columnMap` | `Map`: maps from the user column names to the database column names. This value may be `null`. <br /> |

### setStrict

Added in [API level 14](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setStrict (boolean strict)
```

When set, the selection is verified against malicious arguments. When
using this class to create a statement using
`https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#buildQueryString(boolean,%20java.lang.String,%20java.lang.String[],%20java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String)`,
non-numeric limits will raise an exception. If a projection map is
specified, fields not in that map will be ignored. If this class is used
to execute the statement directly using
`https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#query(android.database.sqlite.SQLiteDatabase,%20java.lang.String[],%20java.lang.String,%20java.lang.String[],%20java.lang.String,%20java.lang.String,%20java.lang.String)`
or
`https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#query(android.database.sqlite.SQLiteDatabase,%20java.lang.String[],%20java.lang.String,%20java.lang.String[],%20java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String)`,
additionally also parenthesis escaping selection are caught. To
summarize: To get maximum protection against malicious third party apps
(for example content provider consumers), make sure to do the following:

- Set this value to true
- Use a projection map
- Use one of the query overloads instead of getting the statement as a sql string


This feature is disabled by default on each newly constructed
`https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder` and needs to be manually enabled.

<br />

| Parameters ||
|---|---|
| `strict` | `boolean` <br /> |

### setStrictColumns

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setStrictColumns (boolean strictColumns)
```

When enabled, verify that all projections and `https://developer.android.com/reference/android/content/ContentValues` only
contain valid columns as defined by `https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#setProjectionMap(java.util.Map<java.lang.String,java.lang.String>)`.


This enforcement applies to `https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#insert(android.database.sqlite.SQLiteDatabase,%20android.content.ContentValues)`, `https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#query(android.database.sqlite.SQLiteDatabase,%20java.lang.String[],%20java.lang.String,%20java.lang.String[],%20java.lang.String,%20java.lang.String,%20java.lang.String)`, and
`https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#update(android.database.sqlite.SQLiteDatabase,%20android.content.ContentValues,%20java.lang.String,%20java.lang.String[])` operations. Any enforcement failures will throw an
`https://developer.android.com/reference/java/lang/IllegalArgumentException`.


This feature is disabled by default on each newly constructed
`https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder` and needs to be manually enabled.

<br />

| Parameters ||
|---|---|
| `strictColumns` | `boolean` <br /> |

### setStrictGrammar

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setStrictGrammar (boolean strictGrammar)
```

When enabled, verify that all untrusted SQL conforms to a restricted SQL
grammar. Here are the restrictions applied:

- In `WHERE` and `HAVING` clauses: subqueries, raising, and windowing terms are rejected.
- In `GROUP BY` clauses: only valid columns are allowed.
- In `ORDER BY` clauses: only valid columns, collation, and ordering terms are allowed.
- In `LIMIT` clauses: only numerical values and offset terms are allowed.

All column references must be valid as defined by `https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#setProjectionMap(java.util.Map<java.lang.String,java.lang.String>)`.


This enforcement applies to `https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#query(android.database.sqlite.SQLiteDatabase,%20java.lang.String[],%20java.lang.String,%20java.lang.String[],%20java.lang.String,%20java.lang.String,%20java.lang.String)`, `https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#update(android.database.sqlite.SQLiteDatabase,%20android.content.ContentValues,%20java.lang.String,%20java.lang.String[])` and
`https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#delete(android.database.sqlite.SQLiteDatabase,%20java.lang.String,%20java.lang.String[])` operations. This enforcement does not apply to trusted
inputs, such as those provided by `https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder#appendWhere(java.lang.CharSequence)`. Any enforcement
failures will throw an `https://developer.android.com/reference/java/lang/IllegalArgumentException`.


This feature is disabled by default on each newly constructed
`https://developer.android.com/reference/android/database/sqlite/SQLiteQueryBuilder` and needs to be manually enabled.

<br />

| Parameters ||
|---|---|
| `strictGrammar` | `boolean` <br /> |

### setTables

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setTables (String inTables)
```

Sets the list of tables to query. Multiple tables can be specified to perform a join.
For example:
setTables("foo, bar")
setTables("foo LEFT OUTER JOIN bar ON (foo.id = bar.foo_id)")

<br />

| Parameters ||
|---|---|
| `inTables` | `String`: the list of tables to query on. This value may be `null`. <br /> |

### update

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int update (SQLiteDatabase db, 
                ContentValues values, 
                String selection, 
                String[] selectionArgs)
```

Perform an update by combining all current settings and the
information passed into this method.

<br />

| Parameters ||
|---|---|
| `db` | `SQLiteDatabase`: the database to update on. This value cannot be `null`. <br /> |
| `values` | `ContentValues`: This value cannot be `null`. <br /> |
| `selection` | `String`: 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. <br /> |
| `selectionArgs` | `String`: 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. This value may be `null`. <br /> |

| Returns ||
|---|---|
| `int` | the number of rows updated <br /> |