Skip to content

SharedPreferencesExtensions

Birju Vachhani edited this page Sep 26, 2019 · 2 revisions

Note that these SharedPreferences extensions only supports primitive types.

Write

    // write async
    pref.write(KEY,"text")
    pref.write(KEY,15)
    pref.write(KEY,30L)
    pref.write(KEY,2.5F)
    pref.write(KEY,true)
    pref.writeSync(KEY,VALUE)

Another Way

    // set async
    pref[KEY] = "text"
    pref[KEY] = 15
    pref[KEY] = 2.8F
    pref[KEY] = 38L
    pref[KEY] = true

Clear SharedPreferences

    pref.clear()

Remove <Key,Value>

    pref.remove(KEY)

For more information, look at the SharedPreferencesExtensions.kt file.

Clone this wiki locally