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

# Builder

*** ** * ** ***

Kotlin \|[Java](https://developer.android.com/reference/android/app/appsearch/SetSchemaRequest.Builder "View this page in Java")

```
class Builder
```

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

Builder for `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest` objects.

## Summary

| Public constructors ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#Builder()()` Creates a new `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#`. |
| `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#Builder(android.app.appsearch.SetSchemaRequest)(request: https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest)` Creates a `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#` from the given `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest`. |

| Public methods ||
|---|---|
| [SetSchemaRequest.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#) | `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#addRequiredPermissionsForSchemaTypeVisibility(kotlin.String,%20kotlin.collections.MutableSet)(schemaType: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html, permissions: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-set/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html!>)` Adds a set of required Android `https://developer.android.com/reference/kotlin/android/Manifest.permission.html#` combination to the given schema type. |
| [SetSchemaRequest.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#) | `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#addSchemaTypeVisibleToConfig(kotlin.String,%20android.app.appsearch.SchemaVisibilityConfig)(schemaType: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html, schemaVisibilityConfig: https://developer.android.com/reference/kotlin/android/app/appsearch/SchemaVisibilityConfig)` Sets the documents from the provided `schemaType` can be read by the caller if they match the ALL visibility requirements set in `https://developer.android.com/reference/kotlin/android/app/appsearch/SchemaVisibilityConfig`. |
| [SetSchemaRequest.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#) | `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#addSchemas(android.app.appsearch.AppSearchSchema)(vararg schemas: https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchSchema!)` Adds one or more `https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchSchema` types to the schema. |
| [SetSchemaRequest.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#) | `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#addSchemas(kotlin.collections.MutableCollection)(schemas: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-collection/index.html<https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchSchema!>)` Adds a collection of `https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchSchema` objects to the schema. |
| [SetSchemaRequest](https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest) | `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#build()()` Builds a new `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest` object. |
| [SetSchemaRequest.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#) | `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#clearMigrators()()` Clears all `https://developer.android.com/reference/kotlin/android/app/appsearch/Migrator`s. |
| [SetSchemaRequest.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#) | `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#clearRequiredPermissionsForSchemaTypeVisibility(kotlin.String)(schemaType: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` Clears all required permissions combinations for the given schema type. |
| [SetSchemaRequest.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#) | `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#clearSchemaTypeVisibleToConfigs(kotlin.String)(schemaType: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` Clears all visible to `https://developer.android.com/reference/kotlin/android/app/appsearch/SchemaVisibilityConfig` for the given schema type. |
| [SetSchemaRequest.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#) | `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#clearSchemas()()` Clears all `https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchSchema`s from the list of schemas. |
| [SetSchemaRequest.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#) | `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#setForceOverride(kotlin.Boolean)(forceOverride: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` Sets whether or not to override the current schema in the `https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchSession` database. |
| [SetSchemaRequest.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#) | `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#setMigrator(kotlin.String,%20android.app.appsearch.Migrator)(schemaType: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html, migrator: https://developer.android.com/reference/kotlin/android/app/appsearch/Migrator)` Sets the `https://developer.android.com/reference/kotlin/android/app/appsearch/Migrator` associated with the given SchemaType. |
| [SetSchemaRequest.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#) | `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#setMigrators(kotlin.collections.MutableMap)(migrators: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-map/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html!, https://developer.android.com/reference/kotlin/android/app/appsearch/Migrator!>)` Sets a Map of `https://developer.android.com/reference/kotlin/android/app/appsearch/Migrator`s. |
| [SetSchemaRequest.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#) | `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#setPubliclyVisibleSchema(kotlin.String,%20android.app.appsearch.PackageIdentifier)(schema: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html, packageIdentifier: https://developer.android.com/reference/kotlin/android/app/appsearch/PackageIdentifier?)` Specify that the schema should be publicly available, to packages which already have visibility to `packageIdentifier`. |
| [SetSchemaRequest.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#) | `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#setSchemaTypeDisplayedBySystem(kotlin.String,%20kotlin.Boolean)(schemaType: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html, displayed: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` Sets whether or not documents from the provided `schemaType` will be displayed and visible on any system UI surface. |
| [SetSchemaRequest.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#) | `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#setSchemaTypeVisibilityForPackage(kotlin.String,%20kotlin.Boolean,%20android.app.appsearch.PackageIdentifier)(schemaType: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html, visible: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html, packageIdentifier: https://developer.android.com/reference/kotlin/android/app/appsearch/PackageIdentifier)` Sets whether or not documents from the provided `schemaType` can be read by the specified package. |
| [SetSchemaRequest.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#) | `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#setVersion(kotlin.Int)(version: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Sets the version number of the overall `https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchSchema` in the database. |

## Public constructors

### Builder

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in [T Extensions 17](https://developer.android.com/sdkExtensions)

```
Builder()
```

Creates a new `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#`.

### Builder

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in [T Extensions 17](https://developer.android.com/sdkExtensions)

```
Builder(request: SetSchemaRequest)
```

Creates a `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#` from the given `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest`.

| Parameters ||
|---|---|
| `request` | [SetSchemaRequest](https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest): This value cannot be `null`. |

## Public methods

### addRequiredPermissionsForSchemaTypeVisibility

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in [T Extensions 3](https://developer.android.com/sdkExtensions)

```
fun addRequiredPermissionsForSchemaTypeVisibility(
    schemaType: String, 
    permissions: MutableSet<Int!>
): SetSchemaRequest.Builder
```

Adds a set of required Android `https://developer.android.com/reference/kotlin/android/Manifest.permission.html#` combination to the given schema type.

If the querier holds ALL of the required permissions in this combination, they will have access to read `https://developer.android.com/reference/kotlin/android/app/appsearch/GenericDocument` objects of the given schema type.

You can call this method to add multiple permission combinations, and the querier will have access if they holds ANY of the combinations.

The supported Permissions are `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest#READ_SMS:kotlin.Int`, `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest#READ_CALENDAR:kotlin.Int`, `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest#READ_CONTACTS:kotlin.Int`, `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest#READ_EXTERNAL_STORAGE:kotlin.Int`, `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest#READ_HOME_APP_SEARCH_DATA:kotlin.Int` and `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest#READ_ASSISTANT_APP_SEARCH_DATA:kotlin.Int`.

The relationship between permissions added in this method and package visibility setting `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#setSchemaTypeVisibilityForPackage(kotlin.String,%20kotlin.Boolean,%20android.app.appsearch.PackageIdentifier)` is "OR". The caller could access the schema if they match ANY requirements. If you want to set "AND" requirements like a caller must hold required permissions AND it is a specified package, please use `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#addSchemaTypeVisibleToConfig(kotlin.String,%20android.app.appsearch.SchemaVisibilityConfig)`.

| Parameters ||
|---|---|
| `schemaType` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html): The schema type to set visibility on. This value cannot be `null`. |
| `permissions` | [MutableSet](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-set/index.html)\<[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)!\>: A set of required Android permissions the caller need to hold to access `https://developer.android.com/reference/kotlin/android/app/appsearch/GenericDocument` objects that under the given schema. Value is one of the following: - `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest#READ_SMS:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest#READ_CALENDAR:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest#READ_CONTACTS:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest#READ_EXTERNAL_STORAGE:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest#READ_HOME_APP_SEARCH_DATA:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest#READ_ASSISTANT_APP_SEARCH_DATA:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest#PRIVATE_COMPUTE_CORE_UID_ACCESS:kotlin.Int` . This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#` | This value cannot be `null`. |

| Exceptions ||
|---|---|
| `java.lang.IllegalArgumentException` | -- if input unsupported permission. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/Manifest.permission.html#READ_SMS:kotlin.String`
- `https://developer.android.com/reference/kotlin/android/Manifest.permission.html#READ_CALENDAR:kotlin.String`
- `https://developer.android.com/reference/kotlin/android/Manifest.permission.html#READ_CONTACTS:kotlin.String`
- `https://developer.android.com/reference/kotlin/android/Manifest.permission.html#READ_EXTERNAL_STORAGE:kotlin.String`
- `https://developer.android.com/reference/kotlin/android/Manifest.permission.html#READ_HOME_APP_SEARCH_DATA:kotlin.String`
- `https://developer.android.com/reference/kotlin/android/Manifest.permission.html#READ_ASSISTANT_APP_SEARCH_DATA:kotlin.String`

### addSchemaTypeVisibleToConfig

Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in [T Extensions 13](https://developer.android.com/sdkExtensions)

```
fun addSchemaTypeVisibleToConfig(
    schemaType: String, 
    schemaVisibilityConfig: SchemaVisibilityConfig
): SetSchemaRequest.Builder
```

Sets the documents from the provided `schemaType` can be read by the caller if they match the ALL visibility requirements set in `https://developer.android.com/reference/kotlin/android/app/appsearch/SchemaVisibilityConfig`.

The requirements in a `https://developer.android.com/reference/kotlin/android/app/appsearch/SchemaVisibilityConfig` is "AND" relationship. A caller must match ALL requirements to access the schema. For example, a caller must hold required permissions AND it is a specified package.

You can call this method repeatedly to add multiple `https://developer.android.com/reference/kotlin/android/app/appsearch/SchemaVisibilityConfig`s, and the querier will have access if they match ANY of the `https://developer.android.com/reference/kotlin/android/app/appsearch/SchemaVisibilityConfig`.

| Parameters ||
|---|---|
| `schemaType` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html): The schema type to set visibility on. This value cannot be `null`. |
| `schemaVisibilityConfig` | [SchemaVisibilityConfig](https://developer.android.com/reference/kotlin/android/app/appsearch/SchemaVisibilityConfig): The `https://developer.android.com/reference/kotlin/android/app/appsearch/SchemaVisibilityConfig` holds all requirements that a call must to match to access the schema. This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#` | This value cannot be `null`. |

### addSchemas

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

```
fun addSchemas(vararg schemas: AppSearchSchema!): SetSchemaRequest.Builder
```

Adds one or more `https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchSchema` types to the schema.

An `https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchSchema` object represents one type of structured data.

Any documents of these types will be displayed on system UI surfaces by default.

| Parameters ||
|---|---|
| `schemas` | [AppSearchSchema](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchSchema)!: This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#` | This value cannot be `null`. |

### addSchemas

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

```
fun addSchemas(schemas: MutableCollection<AppSearchSchema!>): SetSchemaRequest.Builder
```

Adds a collection of `https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchSchema` objects to the schema.

An `https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchSchema` object represents one type of structured data.

| Parameters ||
|---|---|
| `schemas` | [MutableCollection](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-collection/index.html)\<[AppSearchSchema](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchSchema)!\>: This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#` | This value cannot be `null`. |

### build

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

```
fun build(): SetSchemaRequest
```

Builds a new `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest` object.

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest` | This value cannot be `null`. |

| Exceptions ||
|---|---|
| `java.lang.IllegalArgumentException` | if schema types were referenced, but the corresponding `https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchSchema` type was never added. |

### clearMigrators

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in [T Extensions 17](https://developer.android.com/sdkExtensions)

```
fun clearMigrators(): SetSchemaRequest.Builder
```

Clears all `https://developer.android.com/reference/kotlin/android/app/appsearch/Migrator`s.

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#` | This value cannot be `null`. |

### clearRequiredPermissionsForSchemaTypeVisibility

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in [T Extensions 3](https://developer.android.com/sdkExtensions)

```
fun clearRequiredPermissionsForSchemaTypeVisibility(schemaType: String): SetSchemaRequest.Builder
```

Clears all required permissions combinations for the given schema type.

| Parameters ||
|---|---|
| `schemaType` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html): This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#` | This value cannot be `null`. |

### clearSchemaTypeVisibleToConfigs

Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in [T Extensions 13](https://developer.android.com/sdkExtensions)

```
fun clearSchemaTypeVisibleToConfigs(schemaType: String): SetSchemaRequest.Builder
```

Clears all visible to `https://developer.android.com/reference/kotlin/android/app/appsearch/SchemaVisibilityConfig` for the given schema type.

| Parameters ||
|---|---|
| `schemaType` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html): This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#` | This value cannot be `null`. |

### clearSchemas

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in [T Extensions 17](https://developer.android.com/sdkExtensions)

```
fun clearSchemas(): SetSchemaRequest.Builder
```

Clears all `https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchSchema`s from the list of schemas.

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#` | This value cannot be `null`. |

### setForceOverride

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

```
fun setForceOverride(forceOverride: Boolean): SetSchemaRequest.Builder
```

Sets whether or not to override the current schema in the `https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchSession` database.

Call this method whenever backward incompatible changes need to be made by setting `forceOverride` to `true`. As a result, during execution of the setSchema operation, all documents that are incompatible with the new schema will be deleted and the new schema will be saved and persisted.

By default, this is `false`.

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#` | This value cannot be `null`. |

### setMigrator

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

```
fun setMigrator(
    schemaType: String, 
    migrator: Migrator
): SetSchemaRequest.Builder
```

Sets the `https://developer.android.com/reference/kotlin/android/app/appsearch/Migrator` associated with the given SchemaType.

The `https://developer.android.com/reference/kotlin/android/app/appsearch/Migrator` migrates all `https://developer.android.com/reference/kotlin/android/app/appsearch/GenericDocument`s under given schema type from the current version number stored in AppSearch to the final version set via `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#setVersion(kotlin.Int)`.

A `https://developer.android.com/reference/kotlin/android/app/appsearch/Migrator` will be invoked if the current version number stored in AppSearch is different from the final version set via `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#setVersion(kotlin.Int)` and `https://developer.android.com/reference/kotlin/android/app/appsearch/Migrator#shouldMigrate(kotlin.Int,%20kotlin.Int)` returns `true`.

The target schema type of the output `https://developer.android.com/reference/kotlin/android/app/appsearch/GenericDocument` of `https://developer.android.com/reference/kotlin/android/app/appsearch/Migrator#onUpgrade(kotlin.Int,%20kotlin.Int,%20android.app.appsearch.GenericDocument)` or `https://developer.android.com/reference/kotlin/android/app/appsearch/Migrator#onDowngrade(kotlin.Int,%20kotlin.Int,%20android.app.appsearch.GenericDocument)` must exist in this `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest`.

| Parameters ||
|---|---|
| `schemaType` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html): The schema type to set migrator on. This value cannot be `null`. |
| `migrator` | [Migrator](https://developer.android.com/reference/kotlin/android/app/appsearch/Migrator): The migrator translates a document from its current version to the final version set via `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#setVersion(kotlin.Int)`. This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#` | This value cannot be `null`. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#setVersion(kotlin.Int)`
- `https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchSession#setSchema(android.app.appsearch.SetSchemaRequest,%20java.util.concurrent.Executor,%20java.util.concurrent.Executor,%20java.util.function.Consumer)`

### setMigrators

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

```
fun setMigrators(migrators: MutableMap<String!, Migrator!>): SetSchemaRequest.Builder
```

Sets a Map of `https://developer.android.com/reference/kotlin/android/app/appsearch/Migrator`s.

The key of the map is the schema type that the `https://developer.android.com/reference/kotlin/android/app/appsearch/Migrator` value applies to.

The `https://developer.android.com/reference/kotlin/android/app/appsearch/Migrator` migrates all `https://developer.android.com/reference/kotlin/android/app/appsearch/GenericDocument`s under given schema type from the current version number stored in AppSearch to the final version set via `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#setVersion(kotlin.Int)`.

A `https://developer.android.com/reference/kotlin/android/app/appsearch/Migrator` will be invoked if the current version number stored in AppSearch is different from the final version set via `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#setVersion(kotlin.Int)` and `https://developer.android.com/reference/kotlin/android/app/appsearch/Migrator#shouldMigrate(kotlin.Int,%20kotlin.Int)` returns `true`.

The target schema type of the output `https://developer.android.com/reference/kotlin/android/app/appsearch/GenericDocument` of `https://developer.android.com/reference/kotlin/android/app/appsearch/Migrator#onUpgrade(kotlin.Int,%20kotlin.Int,%20android.app.appsearch.GenericDocument)` or `https://developer.android.com/reference/kotlin/android/app/appsearch/Migrator#onDowngrade(kotlin.Int,%20kotlin.Int,%20android.app.appsearch.GenericDocument)` must exist in this `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest`.

| Parameters ||
|---|---|
| `migrators` | [MutableMap](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-map/index.html)\<[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!, [Migrator](https://developer.android.com/reference/kotlin/android/app/appsearch/Migrator)!\>: A `https://developer.android.com/reference/kotlin/java/util/Map.html#` of migrators that translate a document from its current version to the final version set via `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#setVersion(kotlin.Int)`. The key of the map is the schema type that the `https://developer.android.com/reference/kotlin/android/app/appsearch/Migrator` value applies to. This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#` | This value cannot be `null`. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#setVersion(kotlin.Int)`
- `https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchSession#setSchema(android.app.appsearch.SetSchemaRequest,%20java.util.concurrent.Executor,%20java.util.concurrent.Executor,%20java.util.function.Consumer)`

### setPubliclyVisibleSchema

Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in [T Extensions 13](https://developer.android.com/sdkExtensions)

```
fun setPubliclyVisibleSchema(
    schema: String, 
    packageIdentifier: PackageIdentifier?
): SetSchemaRequest.Builder
```

Specify that the schema should be publicly available, to packages which already have visibility to `packageIdentifier`. This visibility is determined by the result of android.content.pm.PackageManager#canPackageQuery.

It is possible for the packageIdentifier parameter to be different from the package performing the indexing. This might happen in the case of an on-device indexer processing information about various packages. The visibility will be the same regardless of which package indexes the document, as the visibility is based on the packageIdentifier parameter.

If this is called repeatedly with the same schema, the `https://developer.android.com/reference/kotlin/android/app/appsearch/PackageIdentifier` in the last call will be used as the "from" package for that schema.

Calling this with packageIdentifier set to null is valid, and will remove public visibility for the schema.

| Parameters ||
|---|---|
| `schema` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html): the schema to make publicly accessible. This value cannot be `null`. |
| `packageIdentifier` | [PackageIdentifier](https://developer.android.com/reference/kotlin/android/app/appsearch/PackageIdentifier)?: if an app can see this package via PackageManager#canPackageQuery, it will be able to see the documents of type `schema`. This value may be `null`. |

### setSchemaTypeDisplayedBySystem

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

```
fun setSchemaTypeDisplayedBySystem(
    schemaType: String, 
    displayed: Boolean
): SetSchemaRequest.Builder
```

Sets whether or not documents from the provided `schemaType` will be displayed and visible on any system UI surface.

This setting applies to the provided `schemaType` only, and does not persist across `https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchSession#setSchema(android.app.appsearch.SetSchemaRequest,%20java.util.concurrent.Executor,%20java.util.concurrent.Executor,%20java.util.function.Consumer)` calls.

The default behavior, if this method is not called, is to allow types to be displayed on system UI surfaces.

| Parameters ||
|---|---|
| `schemaType` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html): The name of an `https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchSchema` within the same `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest`, which will be configured. This value cannot be `null`. |
| `displayed` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): Whether documents of this type will be displayed on system UI surfaces. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#` | This value cannot be `null`. |

### setSchemaTypeVisibilityForPackage

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

```
fun setSchemaTypeVisibilityForPackage(
    schemaType: String, 
    visible: Boolean, 
    packageIdentifier: PackageIdentifier
): SetSchemaRequest.Builder
```

Sets whether or not documents from the provided `schemaType` can be read by the specified package.

Each package is represented by a `https://developer.android.com/reference/kotlin/android/app/appsearch/PackageIdentifier`, containing a package name and a byte array of type `https://developer.android.com/reference/kotlin/android/content/pm/PackageManager.html#CERT_INPUT_SHA256:kotlin.Int`.

To opt into one-way data sharing with another application, the developer will need to explicitly grant the other application's package name and certificate Read access to its data.

For two-way data sharing, both applications need to explicitly grant Read access to one another.

By default, data sharing between applications is disabled.

The relationship between permissions added in this method and package visibility setting `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#setSchemaTypeVisibilityForPackage(kotlin.String,%20kotlin.Boolean,%20android.app.appsearch.PackageIdentifier)` is "OR". The caller could access the schema if they match ANY requirements. If you want to set "AND" requirements like a caller must hold required permissions AND it is a specified package, please use `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#addSchemaTypeVisibleToConfig(kotlin.String,%20android.app.appsearch.SchemaVisibilityConfig)`.

| Parameters ||
|---|---|
| `schemaType` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html): The schema type to set visibility on. This value cannot be `null`. |
| `visible` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): Whether the `schemaType` will be visible or not. |
| `packageIdentifier` | [PackageIdentifier](https://developer.android.com/reference/kotlin/android/app/appsearch/PackageIdentifier): Represents the package that will be granted visibility. This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#` | This value cannot be `null`. |

### setVersion

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

```
fun setVersion(version: Int): SetSchemaRequest.Builder
```

Sets the version number of the overall `https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchSchema` in the database.

The `https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchSession` database can only ever hold documents for one version at a time.

Setting a version number that is different from the version number currently stored in AppSearch will result in AppSearch calling the `https://developer.android.com/reference/kotlin/android/app/appsearch/Migrator`s provided to `https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchSession#setSchema(android.app.appsearch.SetSchemaRequest,%20java.util.concurrent.Executor,%20java.util.concurrent.Executor,%20java.util.function.Consumer)` to migrate the documents already in AppSearch from the previous version to the one set in this request. The version number can be updated without any other changes to the set of schemas.

The version number can stay the same, increase, or decrease relative to the current version number that is already stored in the `https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchSession` database.

The version of an empty database will always be 0. You cannot set version to the `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest`, if it doesn't contains any `https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchSchema`.

| Parameters ||
|---|---|
| `version` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): A positive integer representing the version of the entire set of schemas represents the version of the whole schema in the `https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchSession` database, default version is 1. Value is 1 or greater |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#` | This value cannot be `null`. |

| Exceptions ||
|---|---|
| `java.lang.IllegalArgumentException` | if the version is negative. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchSession#setSchema(android.app.appsearch.SetSchemaRequest,%20java.util.concurrent.Executor,%20java.util.concurrent.Executor,%20java.util.function.Consumer)`
- `https://developer.android.com/reference/kotlin/android/app/appsearch/Migrator`
- `https://developer.android.com/reference/kotlin/android/app/appsearch/SetSchemaRequest.Builder#setMigrator(kotlin.String,%20android.app.appsearch.Migrator)`