Upgrade database versions with ease - MIGRATION • Enforces you don’t perform database operations on the main thread • Checks query at compile time • Testing is easier
Upgrade database versions with ease - MIGRATION • Enforces you don’t perform database operations on the main thread • Checks query at compile time • Testing is easier
Upgrade database versions with ease - MIGRATION • Enforces you don’t perform database operations on the main thread • Checks query at compile time • Testing is easier
Upgrade database versions with ease - MIGRATION • Enforces you don’t perform database operations on the main thread • Checks query at compile time • Testing is easier
Upgrade database versions with ease - MIGRATION • Enforces you don’t perform database operations on the main thread • Checks query at compile time • Testing is easier
Upgrade database versions with ease - MIGRATION • Enforces you don’t perform database operations on the main thread • Checks query at compile time • Testing is easier
insert/delete/update (Attendee attendee); @Query("Select * from attendee where email=:email") Attendee getAttendedByEmail (String email); @Query("Select * from attendee") List<Attendee> getAllAttendees (); } Return a list
Room.databaseBuilder (this, AppDatabase.class, "database_name") .build (); CAUTION!!! Recommended to keep it a singleton ‘cos database calls are not cheap
- IllegalStateException • Increase version, no provision for migration - IllegalStateException • Increase version, enable fallback to destructive migration - wipes data • Increase version, provide migration - preserves data
= new MigrationTestHelper (InstrumentationRegistry.getInstrumentation (), AppDatabase.class.getCanonicalName (), new FrameworkSQLiteOpenHelperFactory ());