# EncryptedSharedPreferencesKt

Added in 1.1.0

*** ** * ** ***


```
public final class EncryptedSharedPreferencesKt
```

<br />

*** ** * ** ***

## Summary

| ### Public methods |
|---|---|
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/SharedPreferences.html` | `[EncryptedSharedPreferences](https://developer.android.com/reference/androidx/security/crypto/EncryptedSharedPreferencesKt#EncryptedSharedPreferences(android.content.Context,kotlin.String,androidx.security.crypto.MasterKey,androidx.security.crypto.EncryptedSharedPreferences.PrefKeyEncryptionScheme,androidx.security.crypto.EncryptedSharedPreferences.PrefValueEncryptionScheme))( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html context, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html fileName, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/security/crypto/MasterKey masterKey, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/security/crypto/EncryptedSharedPreferences.PrefKeyEncryptionScheme prefKeyEncryptionScheme, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/security/crypto/EncryptedSharedPreferences.PrefValueEncryptionScheme prefValueEncryptionScheme )` **This method is deprecated.** Use android.content.SharedPreferences instead |

## Public methods

### EncryptedSharedPreferences

Artifact: [androidx.security:security-crypto-ktx](https://developer.android.com/jetpack/androidx/releases/security) [View Source](https://cs.android.com/search?q=file:androidx/security/crypto/EncryptedSharedPreferences.kt+function:EncryptedSharedPreferences) 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 static final @NonNull SharedPreferences [EncryptedSharedPreferences](https://developer.android.com/reference/androidx/security/crypto/EncryptedSharedPreferencesKt#EncryptedSharedPreferences(android.content.Context,kotlin.String,androidx.security.crypto.MasterKey,androidx.security.crypto.EncryptedSharedPreferences.PrefKeyEncryptionScheme,androidx.security.crypto.EncryptedSharedPreferences.PrefValueEncryptionScheme))(
    @NonNull Context context,
    @NonNull String fileName,
    @NonNull MasterKey masterKey,
    @NonNull EncryptedSharedPreferences.PrefKeyEncryptionScheme prefKeyEncryptionScheme,
    @NonNull EncryptedSharedPreferences.PrefValueEncryptionScheme prefValueEncryptionScheme
)
```

> [!CAUTION]
> **This method is deprecated.**   
> Use android.content.SharedPreferences instead

Opens an instance of encrypted SharedPreferences

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html fileName` | The name of the file to open; can not contain path separators. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/security/crypto/MasterKey masterKey` | The master key to use. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/security/crypto/EncryptedSharedPreferences.PrefKeyEncryptionScheme prefKeyEncryptionScheme` | The scheme to use for encrypting keys. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/security/crypto/EncryptedSharedPreferences.PrefValueEncryptionScheme prefValueEncryptionScheme` | The scheme to use for encrypting values. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/SharedPreferences.html` | The SharedPreferences instance that encrypts all data. |