← ClaudeAtlas

android-datastore-preferenceslisted

DataStore and preferences patterns for Android/KMP - user settings, typed preference models, serialization, migrations from SharedPreferences, corruption handling, and repository boundaries. Use this skill whenever storing app settings, feature flags, lightweight local state, or replacing SharedPreferences. Trigger on phrases like "DataStore", "preferences", "Proto DataStore", "settings", "user preferences", "SharedPreferences migration", or "local settings persistence".
lenorebreakneck630/claude-zero-to-hero-android-KMP · ★ 1 · Data & Documents · score 64
Install: claude install-skill lenorebreakneck630/claude-zero-to-hero-android-KMP
# Android DataStore and Preferences ## Core Principles - Use DataStore for small local settings and preference-like state. - Do not use DataStore as a database or cache for large relational data. - Persist only data that should survive process death and app restarts. - Expose typed models to the rest of the app, not raw preference keys. - Keep storage details inside the data layer. --- ## When to Use DataStore Good fits: - theme mode - onboarding completed flag - sort/filter preferences - selected app language - lightweight session-adjacent non-sensitive flags Bad fits: - large lists of entities - search indexes - offline sync source of truth - highly relational or query-heavy data Use Room for structured app data. See the **android-room-database** skill. --- ## Preferences vs Proto DataStore | Need | Preferred option | |---|---| | Simple key/value settings | Preferences DataStore | | Strong schema and typed persistence | Proto DataStore | | Cross-team/shared contract that should evolve safely | Proto DataStore | Default to Preferences DataStore unless the settings model is large enough or important enough to benefit from a defined schema. --- ## Module Ownership Common placements: ```text :core:data -> shared DataStore factory and generic helpers :core:auth -> secure/session-adjacent non-token local state if needed :feature:<name>:data -> feature-specific preference repositories ``` If settings are shared app-wide, kee