# 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
public final class Account.Builder
```

<br />

*** ** * ** ***

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

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/appsearch/builtintypes/Account.Builder#Builder(androidx.appsearch.builtintypes.Account)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/appsearch/builtintypes/Account account)` Constructor with all the existing values. |
| `https://developer.android.com/reference/androidx/appsearch/builtintypes/Account.Builder#Builder(java.lang.String,java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html namespace, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html id)` Constructor for `https://developer.android.com/reference/androidx/appsearch/builtintypes/Account.Builder`. |

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/appsearch/builtintypes/Account` | `https://developer.android.com/reference/androidx/appsearch/builtintypes/Account.Builder#build()()` Builds a new `Account` instance. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/appsearch/builtintypes/Account.Builder` | `https://developer.android.com/reference/androidx/appsearch/builtintypes/Account.Builder#setAccountId(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html accountId)` Sets the opaque, optional identifier for the account. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/appsearch/builtintypes/Account.Builder` | `https://developer.android.com/reference/androidx/appsearch/builtintypes/Account.Builder#setAccountName(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html accountName)` Sets the human-readable name of the account. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/appsearch/builtintypes/Account.Builder` | `https://developer.android.com/reference/androidx/appsearch/builtintypes/Account.Builder#setAccountType(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html accountType)` 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)

```
public Builder(@NonNull 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)

```
public Builder(@NonNull String namespace, @NonNull String id)
```

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

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html namespace` | Namespace for the Document. See `https://developer.android.com/reference/androidx/appsearch/annotation/Document.Namespace`. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html id` | Unique identifier for the Document. See `https://developer.android.com/reference/androidx/appsearch/annotation/Document.Id`. |

## Public methods

### build

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

```
public @NonNull Account build()
```

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)

```
public @NonNull Account.Builder setAccountId(@NonNull String accountId)
```

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)

```
public @NonNull Account.Builder setAccountName(@NonNull String accountName)
```

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)

```
public @NonNull Account.Builder setAccountType(@NonNull String accountType)
```

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".