Created
July 20, 2022 12:03
-
-
Save wajahatkarim3/0cef79632ef2f84a8c9d7e2baf86f811 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val securePreferences = EncryptedSharedPreferences.create( | |
"secure_prefs", | |
mainKeyAlias, | |
applicationContext, | |
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV, | |
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM | |
) | |
// Storing Data in Preferences | |
with(securePreferences.edit()) { | |
putBoolean("Bool", true) | |
putString("String", "Some normal string value") | |
putInt("Integer", 10) | |
commit() | |
} | |
// Reading data from Preferences | |
val boolValue = securePreferences.getBoolean("Bool", false) | |
val strValue = securePreferences.getString("String", "") | |
val intValue = securePreferences.getInt("Integer", 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment