Stay organized with collections
Save and categorize content based on your preferences.
Builder
class Builder
Builder class for KeyStoreParameter
objects.
This will build protection parameters for use with the Android KeyStore facility.
This can be used to require that KeyStore entries be stored encrypted.
Example:
KeyStoreParameter params = new KeyStoreParameter.Builder(mContext)
.setEncryptionRequired()
.build();
Summary
Public constructors |
Creates a new instance of the Builder with the given context .
|
Public constructors
Builder
Builder(context: Context)
Creates a new instance of the Builder
with the given context
. The context
passed in may be used to pop up some UI to ask the user to unlock or initialize the Android KeyStore facility.
Parameters |
context |
Context: This value cannot be null . |
Public methods
build
fun build(): KeyStoreParameter
Deprecated: Deprecated in Java.
Builds the instance of the KeyStoreParameter
.
Return |
KeyStoreParameter |
built instance of KeyStoreParameter This value cannot be null . |
Exceptions |
java.lang.IllegalArgumentException |
if a required field is missing |
setEncryptionRequired
fun setEncryptionRequired(required: Boolean): KeyStoreParameter.Builder
Deprecated: Data at rest encryption is enabled by default. If extra binding to the lockscreen credential is desired, use .Builder#setUserAuthenticationRequired(boolean)
. This flag will be ignored from Android S.
Sets whether this java.security.KeyStore
entry must be encrypted at rest. Encryption at rest will protect the entry with the secure lock screen credential (e.g., password, PIN, or pattern).
Note that enabling this feature requires that the secure lock screen (e.g., password, PIN, pattern) is set up, otherwise setting the KeyStore
entry will fail. Moreover, this entry will be deleted when the secure lock screen is disabled or reset (e.g., by the user or a Device Administrator). Finally, this entry cannot be used until the user unlocks the secure lock screen after boot.
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,["# KeyStoreParameter.Builder\n\nAdded in [API level 18](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \nDeprecated in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nBuilder\n=======\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/security/KeyStoreParameter.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.security.KeyStoreParameter.Builder](#) |\n\n*** ** * ** ***\n\n| **This class was deprecated in API level 23.**\n|\n| Use [KeyProtection.Builder](/reference/kotlin/android/security/keystore/KeyProtection.Builder) instead.\n\nBuilder class for [KeyStoreParameter](/reference/kotlin/android/security/KeyStoreParameter) objects.\n\nThis will build protection parameters for use with the [Android KeyStore facility](https://developer.android.com/training/articles/keystore.html).\n\nThis can be used to require that KeyStore entries be stored encrypted.\n\nExample: \n\n```kotlin\nKeyStoreParameter params = new KeyStoreParameter.Builder(mContext)\n .setEncryptionRequired()\n .build();\n \n```\n\nSummary\n-------\n\n| Public constructors ||\n|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| [Builder](#Builder(android.content.Context))`(`context:` `[Context](../content/Context.html#)`)` Creates a new instance of the `Builder` with the given `context`. |\n\n| Public methods ||\n|---------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [KeyStoreParameter](/reference/kotlin/android/security/KeyStoreParameter) | [build](#build())`()` Builds the instance of the `KeyStoreParameter`. |\n| [KeyStoreParameter.Builder](#) | [setEncryptionRequired](#setEncryptionRequired(kotlin.Boolean))`(`required:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`)` Sets whether this [java.security.KeyStore](../../java/security/KeyStore.html#) entry must be encrypted at rest. |\n\nPublic constructors\n-------------------\n\n### Builder\n\nAdded in [API level 18](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nBuilder(context: Context)\n```\n\nCreates a new instance of the `Builder` with the given `context`. The `context` passed in may be used to pop up some UI to ask the user to unlock or initialize the Android KeyStore facility.\n\n| Parameters ||\n|-----------|-------------------------------------------------------------------|\n| `context` | [Context](../content/Context.html#): This value cannot be `null`. |\n\nPublic methods\n--------------\n\n### build\n\nAdded in [API level 18](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun build(): KeyStoreParameter\n```\n\n**Deprecated:** *Deprecated in Java.*\n\nBuilds the instance of the `KeyStoreParameter`.\n\n| Return ||\n|---------------------------------------------------------------------------|--------------------------------------------------------------------|\n| [KeyStoreParameter](/reference/kotlin/android/security/KeyStoreParameter) | built instance of `KeyStoreParameter` This value cannot be `null`. |\n\n| Exceptions ||\n|--------------------------------------|--------------------------------|\n| `java.lang.IllegalArgumentException` | if a required field is missing |\n\n### setEncryptionRequired\n\nAdded in [API level 18](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun setEncryptionRequired(required: Boolean): KeyStoreParameter.Builder\n```\n\n**Deprecated:** *Data at rest encryption is enabled by default. If extra binding to the lockscreen credential is desired, use [.Builder#setUserAuthenticationRequired(boolean)](/reference/kotlin/android/security/keystore/KeyGenParameterSpec). This flag will be ignored from Android S.*\n\nSets whether this [java.security.KeyStore](../../java/security/KeyStore.html#) entry must be encrypted at rest. Encryption at rest will protect the entry with the secure lock screen credential (e.g., password, PIN, or pattern).\n\nNote that enabling this feature requires that the secure lock screen (e.g., password, PIN, pattern) is set up, otherwise setting the `KeyStore` entry will fail. Moreover, this entry will be deleted when the secure lock screen is disabled or reset (e.g., by the user or a Device Administrator). Finally, this entry cannot be used until the user unlocks the secure lock screen after boot.\n\n| Return ||\n|--------------------------------|------------------------------|\n| [KeyStoreParameter.Builder](#) | This value cannot be `null`. |\n\n**See Also**\n\n- [android.app.KeyguardManager#isDeviceSecure()](../app/KeyguardManager.html#isDeviceSecure())"]]