Local Storage Interview Questions (Android Native)
6 Local Storage questions from the Android Native track. Read each short answer here, then open a question for the full explanation, examples, common mistakes, and sources.
- Junior
What are the three basic components of the Room library and what is the role of each?
Entity represents database tables and their columns, DAO defines the query and insert operations, and RoomDatabase is the central access point for the connection.
Read the full explanation - Junior
Why is it recommended to move from SharedPreferences to Jetpack DataStore?
Because DataStore is completely thread-safe, relies on Kotlin coroutines and Flow, and handles errors safely without blocking the UI or causing ANR errors.
Read the full explanation - Mid-level
How do you store custom data types (such as dates or lists) in Room using TypeConverters?
By defining functions annotated with @TypeConverter to convert the custom type to a primitive type SQLite understands (such as text or a number) and reverse it on read.
Read the full explanation - Mid-level
How do you handle upgrading the database schema (Room database migrations) without losing user data?
By increasing the version number and writing a Migration object that runs the appropriate ALTER TABLE statements, or relying on AutoMigration if the change is simple.
Read the full explanation - Mid-level
How do you design relationships between tables (one-to-many and many-to-many) in Room?
Using intermediary data objects with the @Embedded and @Relation annotations to specify the foreign key and primary key without complicating queries by hand.
Read the full explanation - Senior
What is the difference between Preferences DataStore and Proto DataStore and when do you choose Proto DataStore?
Preferences DataStore stores key-value pairs with no predefined schema; Proto DataStore stores custom objects with strict, safe data types using Protocol Buffers.
Read the full explanation