This repository was archived by the owner on Feb 16, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,15 +11,14 @@ Usage
1111-----
1212
1313When you want to use shared preferences, you can now call it in
14- a simplified manor.
14+ a simplified manor. EncryptedSharedPreferences also works with this extension.
1515
1616``` kotlin
1717val prefs = context.getSharedPreferences(" nameOfPrefs" , Context .MODE_PRIVATE )
1818
1919.. .
2020
21- // Note, you must use nullable types as SharedPreferences doesn't enforce nullability like kotlin
22- var someField: String? by prefs.delegate()
21+ var someField: String by prefs.delegate()
2322
2423// You can also set a default value and key name for the preferences
2524var someOtherField: String by prefs.delegate(keyName = " SomeCoolPreference" , defaultValue = " Hello" )
@@ -34,9 +33,9 @@ fun doSomething(): String {
3433
3534Supported Types
3635---------------
37- - String
38- - String Set (` Set <String>` )
39- - Int
40- - Long
41- - Float
42- - Boolean
36+ - String (defaultValue is an empty string ` "" ` )
37+ - String Set (defaultValue is an empty StringSet ` emptySet <String>() ` )
38+ - Int (defaultValue is -1)
39+ - Long (defaultValue is -1L)
40+ - Float (defaultValue is 0F)
41+ - Boolean (defaultValue is false)
You can’t perform that action at this time.
0 commit comments