# PlayServicesStorage.SearchContext.Builder

Artifact: [androidx.appsearch:appsearch-play-services-storage](https://developer.android.com/jetpack/androidx/releases/appsearch) [View Source](https://cs.android.com/search?q=file:androidx/appsearch/playservicesstorage/PlayServicesStorage.java+class:androidx.appsearch.playservicesstorage.PlayServicesStorage.SearchContext.Builder) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

*** ** * ** ***


```
public final class PlayServicesStorage.SearchContext.Builder
```

<br />

*** ** * ** ***

Builder for `https://developer.android.com/reference/androidx/appsearch/playservicesstorage/PlayServicesStorage.SearchContext` objects.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/appsearch/playservicesstorage/PlayServicesStorage.SearchContext.Builder#Builder(android.content.Context,java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html databaseName)` Creates a `https://developer.android.com/reference/androidx/appsearch/playservicesstorage/PlayServicesStorage.SearchContext.Builder` instance. |

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/appsearch/playservicesstorage/PlayServicesStorage.SearchContext` | `https://developer.android.com/reference/androidx/appsearch/playservicesstorage/PlayServicesStorage.SearchContext.Builder#build()()` Builds a `https://developer.android.com/reference/androidx/appsearch/playservicesstorage/PlayServicesStorage.SearchContext` instance. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/appsearch/playservicesstorage/PlayServicesStorage.SearchContext.Builder` | `https://developer.android.com/reference/androidx/appsearch/playservicesstorage/PlayServicesStorage.SearchContext.Builder#setWorkerExecutor(java.util.concurrent.Executor)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/concurrent/Executor.html executor)` Sets the worker executor associated with `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSession`. |

## Public constructors

### Builder

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

```
public Builder(@NonNull Context context, @NonNull String databaseName)
```

Creates a `https://developer.android.com/reference/androidx/appsearch/playservicesstorage/PlayServicesStorage.SearchContext.Builder` instance.

`https://developer.android.com/reference/androidx/appsearch/app/AppSearchSession` will create or open a database under the given name.

Databases with different names are fully separate with distinct schema types, namespaces, and documents.

The database name cannot contain `'/'`.

The database name will be visible to all system UI or third-party applications that have been granted access to any of the database's documents (for example, using `https://developer.android.com/reference/androidx/appsearch/app/SetSchemaRequest.Builder#setSchemaTypeVisibilityForPackage(java.lang.String,boolean,androidx.appsearch.app.PackageIdentifier)`).

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context` | The context used as the parent of the created SearchContext |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html databaseName` | The name of the database. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if the databaseName contains `'/'`. |

## Public methods

### build

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

```
public @NonNull PlayServicesStorage.SearchContext build()
```

Builds a `https://developer.android.com/reference/androidx/appsearch/playservicesstorage/PlayServicesStorage.SearchContext` instance.

### setWorkerExecutor

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

```
public @NonNull PlayServicesStorage.SearchContext.Builder setWorkerExecutor(@NonNull Executor executor)
```

Sets the worker executor associated with `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSession`.

If an executor is not provided, the AppSearch default executor will be used.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/concurrent/Executor.html executor` | the worker executor used to run heavy background tasks. |