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

后端 未结 2 1799
轮回少年
轮回少年 2021-01-01 02:40

App Database has Items table with a column Price with datatype Long. Db Version = 1

CREATE TABLE items (_i         


        
相关标签:
2条回答
  • 2021-01-01 03:17

    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.

    0 讨论(0)
  • 2021-01-01 03:25

    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.

    0 讨论(0)
提交回复
热议问题