Editing SharedPreferences with Android KTX

Jetpack includes the Android KTX foundation library. Android KTX is a set of Kotlin extensions that allows you to leverage Kotlin language features when writing code that relies on Android APIs written in Java. Using Android KTX does not change the functionality of the existing Java APIs. But it does help you keep your Kotlin code idiomatic.

As of this writing, Android KTX only includes extensions for a subset of Android Java APIs. See the Android KTX documentation (developer.android.com/​kotlin/​ktx) for a list of available extension modules. However, the core Android KTX module does include an extension for editing shared preferences.

Update QueryPreferences to use Android KTX. First, ...

Get Android Programming: The Big Nerd Ranch Guide, 4th Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.