How to annotate a default value inside a android room entity?

前端 未结 5 856
故里飘歌
故里飘歌 2020-12-09 09:22

I couldn\'t find any information how to annotate a SQL - \"DEFAULT\" value while looking into the @ColumnInfo docs for the new Android Persistence Library.

Does Room

5条回答
  •  清歌不尽
    2020-12-09 10:15

    Room hasn't any annotation for default value, but you can set default value in your entity like this:

    @Entity(tableName = "MyTable")
    class MyClass {
        ...
    
        public String MyDefaultValuedCol = "defaultString";
    
        public boolean MyDefaultFlagCol = true;
    
    }
    

提交回复
热议问题