Create Room Entity for a Table which has a field with LONG datatype in Sqlite

The simple answer is you CANNOT

Room only supports 5 data types which are TEXT, INTEGER, BLOB, REAL and UNDEFINED.

So, java data types of Boolean, Integer, Long will be all converted to INTEGER in SQL.

What you can do is convert your LONG data type to INTEGER in SQL instead of converting INTEGER data type to LONG in Room in order to make Room support LONG, which Room doesn't support.


As from the docs SQLITE doesn't support Long, check docs here.

INTEGER. The value is a signed integer, stored in 1, 2, 3, 4, 6, or 8 bytes depending on the magnitude of the value.

However as LONG is 8 byte and INTEGER can also save values of 8 bytes, you can use INTEGER.


If anyone is still struggling with this, as I did for hours, and not understanding the above solution... just create a new database file in SQLite, copy the SQL statement for creating the table but change every datatype to either TEXT, INTEGER, BLOB, REAL and UNDEFINED,. Then populate the table with copied SQL statement from old DB. Fixed the problem, where simply changing the datatype in SQLite did not.