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

# Builder

*** ** * ** ***

```
class Builder
```

|---|---|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||
| ↳ | [android.provider.PeopleContract.Persons.Query.Builder](https://developer.android.com/reference/kotlin/android/provider/PeopleContract.Persons.Query.Builder#) |

Helper class for building structured query argument bundles to pass into `https://developer.android.com/reference/kotlin/android/content/ContentResolver.html#query(android.net.Uri,%20kotlin.Array,%20android.os.Bundle,%20android.os.CancellationSignal)` when querying `https://developer.android.com/reference/kotlin/android/provider/PeopleContract.Persons#CONTENT_URI:android.net.Uri`, or when minting interaction requests with `https://developer.android.com/reference/kotlin/android/provider/PeopleContract#createPeopleInteractionRequest(android.content.ContentResolver,%20kotlin.String,%20android.os.Bundle)`.

When querying `https://developer.android.com/reference/kotlin/android/provider/PeopleContract.Persons#CONTENT_URI:android.net.Uri`, multiple sub-queries targeting different directory packages or selection criteria can be combined onto a single builder instance before calling `https://developer.android.com/reference/kotlin/android/provider/PeopleContract.Persons.Query.Builder#build()`. When used with `https://developer.android.com/reference/kotlin/android/provider/PeopleContract#createPeopleInteractionRequest(android.content.ContentResolver,%20kotlin.String,%20android.os.Bundle)`, exactly one sub-query targeting a single People Directory application must be configured.

## Summary

| Public constructors ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/provider/PeopleContract.Persons.Query.Builder#Builder()()` Constructs a new empty instance of `https://developer.android.com/reference/kotlin/android/provider/PeopleContract.Persons.Query.Builder#`. |

| Public methods ||
|---|---|
| [PeopleContract.Persons.Query.Builder](https://developer.android.com/reference/kotlin/android/provider/PeopleContract.Persons.Query.Builder#) | `https://developer.android.com/reference/kotlin/android/provider/PeopleContract.Persons.Query.Builder#addEmailQuery(kotlin.String,%20kotlin.collections.MutableList)(packageName: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html, emailAddresses: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html!>)` Adds a sub-query searching for person records that match the given list of email addresses within the specified directory package. |
| [PeopleContract.Persons.Query.Builder](https://developer.android.com/reference/kotlin/android/provider/PeopleContract.Persons.Query.Builder#) | `https://developer.android.com/reference/kotlin/android/provider/PeopleContract.Persons.Query.Builder#addGroupQuery(kotlin.String,%20kotlin.collections.MutableList)(packageName: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html, groupLookupKeys: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html!>)` Adds a sub-query searching for person records that are members of groups matching the given list of group lookup keys within the specified directory package. |
| [PeopleContract.Persons.Query.Builder](https://developer.android.com/reference/kotlin/android/provider/PeopleContract.Persons.Query.Builder#) | `https://developer.android.com/reference/kotlin/android/provider/PeopleContract.Persons.Query.Builder#addLookupQuery(kotlin.String,%20kotlin.collections.MutableList)(packageName: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html, lookupKeys: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html!>)` Adds a sub-query searching for specific person records matching the given list of opaque lookup keys within the specified directory package. |
| [PeopleContract.Persons.Query.Builder](https://developer.android.com/reference/kotlin/android/provider/PeopleContract.Persons.Query.Builder#) | `https://developer.android.com/reference/kotlin/android/provider/PeopleContract.Persons.Query.Builder#addPhoneQuery(kotlin.String,%20kotlin.collections.MutableList)(packageName: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html, phones: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html!>)` Adds a sub-query searching for person records that match the given list of phone numbers within the specified directory package. |
| [Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#) | `https://developer.android.com/reference/kotlin/android/provider/PeopleContract.Persons.Query.Builder#build()()` Generates the final query arguments `https://developer.android.com/reference/kotlin/android/os/Bundle.html#` containing all configured sub-queries. |

## Public constructors

### Builder

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

```
Builder()
```

Constructs a new empty instance of `https://developer.android.com/reference/kotlin/android/provider/PeopleContract.Persons.Query.Builder#`.

## Public methods

### addEmailQuery

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

```
fun addEmailQuery(
    packageName: String, 
    emailAddresses: MutableList<String!>
): PeopleContract.Persons.Query.Builder
```

Adds a sub-query searching for person records that match the given list of email addresses within the specified directory package.

| Parameters ||
|---|---|
| `packageName` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html): The package name of the target directory application. This value cannot be `null`. |
| `emailAddresses` | [MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)\<[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!\>: A list of email address strings to search for. This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/provider/PeopleContract.Persons.Query.Builder#` | This builder instance for method chaining. This value cannot be `null`. |

### addGroupQuery

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

```
fun addGroupQuery(
    packageName: String, 
    groupLookupKeys: MutableList<String!>
): PeopleContract.Persons.Query.Builder
```

Adds a sub-query searching for person records that are members of groups matching the given list of group lookup keys within the specified directory package.

| Parameters ||
|---|---|
| `packageName` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html): The package name of the target directory application. This value cannot be `null`. |
| `groupLookupKeys` | [MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)\<[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!\>: A list of group lookup key strings to search within. This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/provider/PeopleContract.Persons.Query.Builder#` | This builder instance for method chaining. This value cannot be `null`. |

### addLookupQuery

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

```
fun addLookupQuery(
    packageName: String, 
    lookupKeys: MutableList<String!>
): PeopleContract.Persons.Query.Builder
```

Adds a sub-query searching for specific person records matching the given list of opaque lookup keys within the specified directory package.

| Parameters ||
|---|---|
| `packageName` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html): The package name of the target directory application. This value cannot be `null`. |
| `lookupKeys` | [MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)\<[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!\>: A list of person lookup key strings to resolve. This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/provider/PeopleContract.Persons.Query.Builder#` | This builder instance for method chaining. This value cannot be `null`. |

### addPhoneQuery

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

```
fun addPhoneQuery(
    packageName: String, 
    phones: MutableList<String!>
): PeopleContract.Persons.Query.Builder
```

Adds a sub-query searching for person records that match the given list of phone numbers within the specified directory package.

| Parameters ||
|---|---|
| `packageName` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html): The package name of the target directory application. This value cannot be `null`. |
| `phones` | [MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)\<[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!\>: A list of phone number strings to search for. Required to be in E.164 standard format. This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/provider/PeopleContract.Persons.Query.Builder#` | This builder instance for method chaining. This value cannot be `null`. |

### build

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

```
fun build(): Bundle
```

Generates the final query arguments `https://developer.android.com/reference/kotlin/android/os/Bundle.html#` containing all configured sub-queries.

The returned bundle can be passed directly as the query arguments parameter to `https://developer.android.com/reference/kotlin/android/content/ContentResolver.html#query(android.net.Uri,%20kotlin.Array,%20android.os.Bundle,%20android.os.CancellationSignal)`.

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/os/Bundle.html#` | A `https://developer.android.com/reference/kotlin/android/os/Bundle.html#` containing the accumulated query requests under `https://developer.android.com/reference/kotlin/android/provider/PeopleContract#QUERY_ARG_QUERIES:kotlin.String`. This value cannot be `null`. |