Stay organized with collections
Save and categorize content based on your preferences.
Builder
class Builder
Builder for SearchContext
objects.
Summary
Public constructors
Builder
Builder(databaseName: String)
Creates a new SearchContext.Builder
.
AppSearchSession
will create or open a database under the given name.
Databases with different names are fully separate with distinct types, namespaces, and data.
Database name cannot contain '/'
.
Parameters |
databaseName |
String: The name of the database. This value cannot be null . |
Exceptions |
java.lang.IllegalArgumentException |
if the databaseName contains '/' . |
Public methods
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# AppSearchManager.SearchContext.Builder\n\nAdded in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nBuilder\n=======\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/app/appsearch/AppSearchManager.SearchContext.Builder \"View this page in Java\") \n\n```\nclass Builder\n```\n\n|---|-------------------------------------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.app.appsearch.AppSearchManager.SearchContext.Builder](#) |\n\nBuilder for [SearchContext](/reference/kotlin/android/app/appsearch/AppSearchManager.SearchContext) objects.\n\nSummary\n-------\n\n| Public constructors ||\n|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| [Builder](#Builder(kotlin.String))`(`databaseName:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`)` Creates a new [SearchContext.Builder](#). |\n\n| Public methods ||\n|----------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------|\n| [AppSearchManager.SearchContext](/reference/kotlin/android/app/appsearch/AppSearchManager.SearchContext) | [build](#build())`()` Builds a [SearchContext](/reference/kotlin/android/app/appsearch/AppSearchManager.SearchContext) instance. |\n\nPublic constructors\n-------------------\n\n### Builder\n\nAdded in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nBuilder(databaseName: String)\n```\n\nCreates a new [SearchContext.Builder](#).\n\n[AppSearchSession](/reference/kotlin/android/app/appsearch/AppSearchSession) will create or open a database under the given name.\n\nDatabases with different names are fully separate with distinct types, namespaces, and data.\n\nDatabase name cannot contain `'/'`.\n\n| Parameters ||\n|----------------|------------------------------------------------------------------------------------------------------------------------------------------|\n| `databaseName` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html): The name of the database. This value cannot be `null`. |\n\n| Exceptions ||\n|--------------------------------------|-------------------------------------|\n| `java.lang.IllegalArgumentException` | if the databaseName contains `'/'`. |\n\nPublic methods\n--------------\n\n### build\n\nAdded in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun build(): AppSearchManager.SearchContext\n```\n\nBuilds a [SearchContext](/reference/kotlin/android/app/appsearch/AppSearchManager.SearchContext) instance.\n\n| Return ||\n|----------------------------------------------------------------------------------------------------------|------------------------------|\n| [AppSearchManager.SearchContext](/reference/kotlin/android/app/appsearch/AppSearchManager.SearchContext) | This value cannot be `null`. |"]]