# SchemaVisibilityConfig.Builder

Artifact: [androidx.appsearch:appsearch](https://developer.android.com/jetpack/androidx/releases/appsearch) [View Source](https://cs.android.com/search?q=file:androidx/appsearch/app/SchemaVisibilityConfig.java+class:androidx.appsearch.app.SchemaVisibilityConfig.Builder) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

*** ** * ** ***

<br />

```
class SchemaVisibilityConfig.Builder
```

<br />

*** ** * ** ***

The builder class of `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SchemaVisibilityConfig`.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SchemaVisibilityConfig.Builder#Builder()()` Creates a `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SchemaVisibilityConfig.Builder` for a `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SchemaVisibilityConfig`. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SchemaVisibilityConfig.Builder` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SchemaVisibilityConfig.Builder#addAllowedPackage(androidx.appsearch.app.PackageIdentifier)(packageIdentifier: https://developer.android.com/reference/kotlin/androidx/appsearch/app/PackageIdentifier)` Add `https://developer.android.com/reference/kotlin/androidx/appsearch/app/PackageIdentifier` of packages which has access to this schema. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SchemaVisibilityConfig.Builder` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SchemaVisibilityConfig.Builder#addRequiredPermissions(java.util.Set<java.lang.Integer>)(visibleToPermissions: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-set/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html!>)` Adds a set of required Android `https://developer.android.com/reference/android/Manifest.permission.html` combination a package needs to hold to access the schema this `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SchemaVisibilityConfig` represents. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SchemaVisibilityConfig` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SchemaVisibilityConfig.Builder#build()()` Build a `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SchemaVisibilityConfig` |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SchemaVisibilityConfig.Builder` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SchemaVisibilityConfig.Builder#clearAllowedPackages()()` Clears the list of packages which have access to this schema. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SchemaVisibilityConfig.Builder` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SchemaVisibilityConfig.Builder#clearRequiredPermissions()()` Clears all required permissions combinations set to this `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SchemaVisibilityConfig`. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SchemaVisibilityConfig.Builder` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SchemaVisibilityConfig.Builder#setPubliclyVisibleTargetPackage(androidx.appsearch.app.PackageIdentifier)(packageIdentifier: https://developer.android.com/reference/kotlin/androidx/appsearch/app/PackageIdentifier?)` Specify that this schema should be publicly available, to the same packages that have visibility to the package passed as a parameter. |

## Public constructors

### Builder

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
Builder()
```

Creates a `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SchemaVisibilityConfig.Builder` for a `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SchemaVisibilityConfig`.

## Public functions

### addAllowedPackage

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun addAllowedPackage(packageIdentifier: PackageIdentifier): SchemaVisibilityConfig.Builder
```

Add `https://developer.android.com/reference/kotlin/androidx/appsearch/app/PackageIdentifier` of packages which has access to this schema.

### addRequiredPermissions

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun addRequiredPermissions(visibleToPermissions: (Mutable)Set<Int!>): SchemaVisibilityConfig.Builder
```

Adds a set of required Android `https://developer.android.com/reference/android/Manifest.permission.html` combination a package needs to hold to access the schema this `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SchemaVisibilityConfig` represents.

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

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

Merged Set available from `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SchemaVisibilityConfig#getRequiredPermissions()`.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SetSchemaRequest.Builder#addRequiredPermissionsForSchemaTypeVisibility(java.lang.String,java.util.Set<java.lang.Integer>)` | for supported Permissions. |

### build

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun build(): SchemaVisibilityConfig
```

Build a `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SchemaVisibilityConfig`

### clearAllowedPackages

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun clearAllowedPackages(): SchemaVisibilityConfig.Builder
```

Clears the list of packages which have access to this schema.

### clearRequiredPermissions

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun clearRequiredPermissions(): SchemaVisibilityConfig.Builder
```

Clears all required permissions combinations set to this `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SchemaVisibilityConfig`.

### setPubliclyVisibleTargetPackage

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun setPubliclyVisibleTargetPackage(packageIdentifier: PackageIdentifier?): SchemaVisibilityConfig.Builder
```

Specify that this schema should be publicly available, to the same packages that have visibility to the package passed as a parameter. This visibility is determined by the result of `https://developer.android.com/reference/android/content/pm/PackageManager.html#canPackageQuery(java.lang.String, java.lang.String)`.

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.

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

| Parameters |
|---|---|
| `packageIdentifier: https://developer.android.com/reference/kotlin/androidx/appsearch/app/PackageIdentifier?` | the `https://developer.android.com/reference/kotlin/androidx/appsearch/app/PackageIdentifier` of the package that will be used as the target package in a call to `https://developer.android.com/reference/android/content/pm/PackageManager.html#canPackageQuery(java.lang.String, java.lang.String)` to determine which packages can access this publicly visible schema. |