Local Data for Android Developers
Local data on Android is information stored on the device so the app works offline and remembers settings. Room provides a typed SQLite layer with entities, DAOs and migrations, DataStore holds small key-value or typed preferences, and files or encrypted storage handle documents and sensitive values.
Stage: Data and Networking · Part of the Android Developer roadmap · Last reviewed 19 November 2026
What to learn in Local Data
- Define a Room entity, a DAO and a database class
- Return query results as Flow so the UI updates automatically
- Write a Room migration when the schema changes
- Store user preferences with Preferences DataStore
- Choose between internal storage, app-specific files and encrypted storage
Local Data interview questions
When should you use DataStore instead of Room?
Use DataStore for small, simple data such as settings, flags or a signed-in user id, where you read and write whole values. Use Room when you have many records, relationships, filtering or sorting needs. DataStore is asynchronous and built on coroutines and Flow, unlike the old SharedPreferences.
Why must Room queries not run on the main thread?
Disk access can take long enough to freeze the UI and trigger an Application Not Responding dialog, so Room throws an exception for main thread queries by default. Declaring DAO methods as suspend functions or returning Flow makes Room run them on a background executor.
Where Local Data fits in the Android Developer roadmap
Local Data belongs to the Data and Networking stage (beginner level), which takes about 5 hours. Storage and APIs.
Other units in this stage
Back to the full Android Developer roadmap