0Pricing
Android Academy · Lesson

SharedPreferences

Persist simple key-value data across app sessions using SharedPreferences. Learn to save, read, and remove preferences.

Persistent Storage Options

Android offers several ways to store data locally:

  • SharedPreferences — simple key-value pairs (settings, tokens)
  • Room — structured SQLite database (complex data)
  • DataStore — modern async replacement for SharedPreferences
  • Files — raw file I/O

SharedPreferences is perfect for simple settings and user preferences.

What Is SharedPreferences?

SharedPreferences stores data as key-value pairs in an XML file on the device. It supports:

  • String
  • Int / Long / Float
  • Boolean
  • Set<String>

Data persists across app restarts and survives configuration changes (rotation).

All lessons in this course

  1. Kotlin Collections
  2. RecyclerView Basics
  3. RecyclerView Click Events
  4. SharedPreferences
  5. DataStore Preferences
  6. Adapters & DiffUtil
← Back to Android Academy