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

Unlock the full course today

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

Manage shared preferences with code

Manage shared preferences with code

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

Start my 1-month free trial

Manage shared preferences with code

- [Instructor] In Android, a shared preference is a value that's stored in an unencrypted XML file. It's stored in the app's internal storage area, so it isn't visible to the user. You don't have to read or write the XML file directly, that's all done by the Android SDK for you. You just need to know how to create and how to read preferences in your chosen programming language. In this branch of the exercise files, I've added a few files and a bit of code. I've added a couple of vector drawables here and they represent either a list or a grid and I'll preview this file, so we can see what it looks like I've also added a new menu file that lets me choose either a grid or a list, and these menu appear on the action bar. So, now, when I run the app I see these buttons on the toolbar, and I can press them but they aren't doing anything. My goal is to set up a preference that's saved persistently that I can use to decide whether to display my data in a list or a grid. And, finally, in the…

Contents