What problem does it solve?
DataStore is the modern replacement for SharedPreferences, enabling coroutine-based, type-safe storage for lightweight user data such as preferences, theme settings, onboarding state, and non-secure tokens. It also provides a straightforward migration path from SharedPreferences and integrates smoothly with DI and repository patterns.
Core Features & Use Cases
- Preferences DataStore for simple key-value storage with type-safe keys and Flow-based observation.
- Proto DataStore for complex structured data with generated serializers.
- Automatic migration from SharedPreferences to preserve existing user data and ease app upgrades.
- DI-ready modules and repository patterns for clean, testable data access.
- Use Case: Persist user theme, language, and onboarding state across app restarts and configuration changes.
Quick Start
Create a DataStore instance and read or write a sample preference using a coroutine-based repository.