0
0
Android Kotlinmobile~5 mins

Database migrations in Android Kotlin - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a database migration in Android development?
A database migration is the process of updating the database schema when the app's data structure changes, without losing existing user data.
Click to reveal answer
beginner
Why are database migrations important?
They ensure that users keep their data intact when the app updates its database schema, preventing crashes and data loss.
Click to reveal answer
intermediate
In Room database, what class helps define migrations?
The Migration class helps define how to convert the database from one version to another by overriding the migrate() method.
Click to reveal answer
beginner
What is the role of the version number in database migrations?
The version number tells the app which schema version the database currently has and which version it should migrate to.
Click to reveal answer
intermediate
How do you apply multiple migrations in Room?
You provide all Migration objects in the Room.databaseBuilder using addMigrations() so Room can apply them in order.
Click to reveal answer
What happens if you change the database schema without a migration?
AThe app may crash or lose data
BThe app updates automatically without issues
CThe database version stays the same
DThe app ignores the schema change
Which method do you override to define migration steps in Room?
AonUpgrade()
BonCreate()
CupdateSchema()
Dmigrate()
What does the version number in Room database represent?
AThe number of migrations
BThe schema version of the database
CThe number of tables
DThe app version
How do you tell Room to use migrations?
ABy changing the app version
BBy deleting the old database
CBy calling addMigrations() on the database builder
DBy calling migrateDatabase()
If you skip a migration version, what happens?
ARoom throws an exception at runtime
BRoom automatically fixes it
CThe app ignores the missing migration
DThe database resets to empty
Explain how to create and apply a database migration in an Android app using Room.
Think about how you tell Room to move from one schema version to another safely.
You got /4 concepts.
    Why is it important to handle database migrations carefully in mobile apps?
    Consider what happens if the app updates but the database does not.
    You got /4 concepts.