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?
✗ Incorrect
Without a migration, the app cannot handle the schema change and may crash or lose user data.
Which method do you override to define migration steps in Room?
✗ Incorrect
The migrate() method in the Migration class defines how to update the database schema.
What does the version number in Room database represent?
✗ Incorrect
The version number represents the current schema version of the database.
How do you tell Room to use migrations?
✗ Incorrect
You use addMigrations() to provide migration steps to Room.
If you skip a migration version, what happens?
✗ Incorrect
Room requires all migration steps; skipping causes a runtime error.
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.