Android Preferences

In the previous chapter, we were dealing with complex data that was stored in the SQLite database. This time, we will deal with a much simpler form of data. We will cover one particular case of use to demonstrate the use of Android shared preferences.

Let's say that we want to remember the last page position of our ViewPager class and to open it every time an application is started. We will use shared preferences to remember it and persist that information on each view page position change and retrieve it when it is needed.

In this rather short chapter, we will cover the following topics:

  • What are Android's preferences and how can you use them?
  • Defining your own preferences manager

Get Mastering Android Development with Kotlin now with O’Reilly online learning.

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