# Account.Builder

Artifact: [androidx.appsearch:appsearch-builtin-types](https://developer.android.com/jetpack/androidx/releases/appsearch) [View Source](https://cs.android.com/search?q=file:androidx/appsearch/builtintypes/Account.java+class:androidx.appsearch.builtintypes.Account.Builder) Added in [1.2.0-alpha02](https://developer.android.com/jetpack/androidx/releases/appsearch#1.2.0-alpha02)

*** ** * ** ***


```
@Document.BuilderProducer
class Account.Builder
```

<br />

*** ** * ** ***

Builder for `https://developer.android.com/reference/kotlin/androidx/appsearch/builtintypes/Account`.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/appsearch/builtintypes/Account.Builder#Builder(androidx.appsearch.builtintypes.Account)(account: https://developer.android.com/reference/kotlin/androidx/appsearch/builtintypes/Account)` Constructor with all the existing values. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/builtintypes/Account.Builder#Builder(java.lang.String,java.lang.String)(namespace: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Constructor for `https://developer.android.com/reference/kotlin/androidx/appsearch/builtintypes/Account.Builder`. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appsearch/builtintypes/Account` | `https://developer.android.com/reference/kotlin/androidx/appsearch/builtintypes/Account.Builder#build()()` Builds a new `Account` instance. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/builtintypes/Account.Builder` | `https://developer.android.com/reference/kotlin/androidx/appsearch/builtintypes/Account.Builder#setAccountId(java.lang.String)(accountId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Sets the opaque, optional identifier for the account. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/builtintypes/Account.Builder` | `https://developer.android.com/reference/kotlin/androidx/appsearch/builtintypes/Account.Builder#setAccountName(java.lang.String)(accountName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Sets the human-readable name of the account. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/builtintypes/Account.Builder` | `https://developer.android.com/reference/kotlin/androidx/appsearch/builtintypes/Account.Builder#setAccountType(java.lang.String)(accountType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Sets the type of the account. |

## Public constructors

### Builder

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

```
Builder(account: Account)
```

Constructor with all the existing values.

### Builder

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

```
Builder(namespace: String, id: String)
```

Constructor for `https://developer.android.com/reference/kotlin/androidx/appsearch/builtintypes/Account.Builder`.

| Parameters |
|---|---|
| `namespace: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | Namespace for the Document. See `https://developer.android.com/reference/kotlin/androidx/appsearch/annotation/Document.Namespace`. |
| `id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | Unique identifier for the Document. See `https://developer.android.com/reference/kotlin/androidx/appsearch/annotation/Document.Id`. |

## Public functions

### build

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

```
fun build(): Account
```

Builds a new `Account` instance.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | If the validation checks fail. This occurs if: - \*\*`accountType` is an empty string.\*\* - \*\*Both `accountName` and `accountId` are empty strings.\*\* \*\*The constructor requires a non-empty `accountType` and at least one of\*\* \*\*`accountName` or `accountId` to be non-empty.\*\* |

### setAccountId

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

```
fun setAccountId(accountId: String): Account.Builder
```

Sets the opaque, optional identifier for the account. This is the unique ID assigned to the account by service provider (the Authenticator) itself (for example, a Service-Specific User ID). It is used for authentication and service interaction.

### setAccountName

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

```
fun setAccountName(accountName: String): Account.Builder
```

Sets the human-readable name of the account.

### setAccountType

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

```
fun setAccountType(accountType: String): Account.Builder
```

Sets the type of the account. This is typically the package name or a unique identifier of the app or system that owns and manages this account. Example: "com.your.app".