From the course: Android Development Essential Training: Manage Data with Kotlin

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Create a shared preferences activity

Create a shared preferences activity

From the course: Android Development Essential Training: Manage Data with Kotlin

Start my 1-month free trial

Create a shared preferences activity

- Shared preferences can be set in code or with a preferences screen. The easiest way to get started with a screen is to create a new settings activity with Android Studio's code generation tools. In this branch of my exercise files, I've added a bit of code. In my options menu, I've added a new settings item, but in order to do something when the user selects that item I need to create the screen itself. I go to my app module and I'll create a new activity. And I'll choose the settings activity template. For the parent activity I'll choose my main activity and this will let me easily go back to the main activity after going through the settings. And then I'll click finish to create the file. Now a bunch of changes get made when you this. First of all let's look at the Gradle Scripts. You'll see that there's a new dependency for the preference library from Android X. As of the time of this recording, Android studio generated something with a version of alpha zero five. But there's a…

Contents