Migrate to Android Room with Date column – Android

Migrating our apps to Android Room from conventional SQLite Database was flawless except when we encountered issue with Date column type. Issue was that Android Room does not supported by the date column type. Let's suppose we have created table in SQLite database with following CREATE statement and we want to upgrade this table to Android Room. CREATE TABLE tblContact ( _id INTEGER, name TEXT, contact TEXT, created_on DATE, PRIMARY KEY(_id) ) To migrate this table to Android Room we need to follow four simple steps. Create Entity ClassCreate Type ConverterUpdate Entity class to use Long instead of Date Provide migration to incorporate the column data type changeUpdate database version and add migration Step1: Create Entity class While migrating the first step is to create an Entity class for the…
Read More