Storing data locally with SharedPreferences

First and foremost, we need to take care of local storage. As this is a simple application, we do not need to store much data locally. The only data we need to store on the device are access tokens and user details. We will be using SharedPreferences to do this.

First things first, create a data package within the application's source package. We previously identified that we are going to be working with data stored locally and remotely. Hence, create two additional packages within data. Name the first local and the second remote. Similar to the approach that we used for the Tetris application that we created in Chapter 2, Building an Android Application – Tetris and Chapter 3, Implementing Tetris ...

Get Kotlin Programming By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.