# EncryptedFile.Builder

Artifact: [androidx.security:security-crypto](https://developer.android.com/jetpack/androidx/releases/security) [View Source](https://cs.android.com/search?q=file:androidx/security/crypto/EncryptedFile.java+class:androidx.security.crypto.EncryptedFile.Builder) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/security#1.0.0) Deprecated in [1.1.0](https://developer.android.com/jetpack/androidx/releases/security#1.1.0)

*** ** * ** ***


```
public final class EncryptedFile.Builder
```

<br />

*** ** * ** ***

> [!CAUTION]
> **This class is deprecated.**   
>
> Use `https://developer.android.com/reference/java/io/File.html` instead.

Builder class to configure EncryptedFile

## Summary

| ### Public constructors |
|---|
| `[Builder](https://developer.android.com/reference/androidx/security/crypto/EncryptedFile.Builder#Builder(android.content.Context,java.io.File,androidx.security.crypto.MasterKey,androidx.security.crypto.EncryptedFile.FileEncryptionScheme))( @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/io/File.html file, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/security/crypto/MasterKey masterKey, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/security/crypto/EncryptedFile.FileEncryptionScheme fileEncryptionScheme )` **This method is deprecated.** Deprecated in Java |
| `[Builder](https://developer.android.com/reference/androidx/security/crypto/EncryptedFile.Builder#Builder(java.io.File,android.content.Context,java.lang.String,androidx.security.crypto.EncryptedFile.FileEncryptionScheme))( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/io/File.html file, @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 masterKeyAlias, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/security/crypto/EncryptedFile.FileEncryptionScheme fileEncryptionScheme )` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/security/crypto/EncryptedFile.Builder#Builder(android.content.Context,java.io.File,androidx.security.crypto.MasterKey,androidx.security.crypto.EncryptedFile.FileEncryptionScheme)` instead. <br /> |

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/security/crypto/EncryptedFile` | `[build](https://developer.android.com/reference/androidx/security/crypto/EncryptedFile.Builder#build())()` **This method is deprecated.** Deprecated in Java |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/security/crypto/EncryptedFile.Builder` | `[setKeysetAlias](https://developer.android.com/reference/androidx/security/crypto/EncryptedFile.Builder#setKeysetAlias(java.lang.String))(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html keysetAlias)` **This method is deprecated.** Deprecated in Java |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/security/crypto/EncryptedFile.Builder` | `[setKeysetPrefName](https://developer.android.com/reference/androidx/security/crypto/EncryptedFile.Builder#setKeysetPrefName(java.lang.String))(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html keysetPrefName)` **This method is deprecated.** Deprecated in Java |

## Public constructors

### Builder

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

```
public [Builder](https://developer.android.com/reference/androidx/security/crypto/EncryptedFile.Builder#Builder(android.content.Context,java.io.File,androidx.security.crypto.MasterKey,androidx.security.crypto.EncryptedFile.FileEncryptionScheme))(
    @NonNull Context context,
    @NonNull File file,
    @NonNull MasterKey masterKey,
    @NonNull EncryptedFile.FileEncryptionScheme fileEncryptionScheme
)
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

Builder for an EncryptedFile.

### Builder

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

```
public [Builder](https://developer.android.com/reference/androidx/security/crypto/EncryptedFile.Builder#Builder(java.io.File,android.content.Context,java.lang.String,androidx.security.crypto.EncryptedFile.FileEncryptionScheme))(
    @NonNull File file,
    @NonNull Context context,
    @NonNull String masterKeyAlias,
    @NonNull EncryptedFile.FileEncryptionScheme fileEncryptionScheme
)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/security/crypto/EncryptedFile.Builder#Builder(android.content.Context,java.io.File,androidx.security.crypto.MasterKey,androidx.security.crypto.EncryptedFile.FileEncryptionScheme)` instead.

Builder for an EncryptedFile.

If the `masterKeyAlias` used here is for a key that is not yet created, this method will not be thread safe. Use the alternate signature that is not deprecated for multi-threaded contexts.

## Public methods

### build

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

```
public @NonNull EncryptedFile [build](https://developer.android.com/reference/androidx/security/crypto/EncryptedFile.Builder#build())()
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/security/crypto/EncryptedFile` | An EncryptedFile with the specified parameters. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/security/GeneralSecurityException.html` |   |
| `https://developer.android.com/reference/java/io/IOException.html` |   |

### setKeysetAlias

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

```
public @NonNull EncryptedFile.Builder [setKeysetAlias](https://developer.android.com/reference/androidx/security/crypto/EncryptedFile.Builder#setKeysetAlias(java.lang.String))(@NonNull String keysetAlias)
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html keysetAlias` | The alias in the SharedPreferences file to store the keyset. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/security/crypto/EncryptedFile.Builder` | This Builder |

### setKeysetPrefName

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

```
public @NonNull EncryptedFile.Builder [setKeysetPrefName](https://developer.android.com/reference/androidx/security/crypto/EncryptedFile.Builder#setKeysetPrefName(java.lang.String))(@NonNull String keysetPrefName)
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html keysetPrefName` | The SharedPreferences file to store the keyset. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/security/crypto/EncryptedFile.Builder` | This Builder |