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

前端 未结 5 862
故里飘歌
故里飘歌 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:18

    You can set the default value using @ColumnInfo annotation-

    @ColumnInfo(defaultValue = "No name")
    public String name;
    

    and

    @ColumnInfo(defaultValue = "0")
    public int flag;
    

    or for any kind of data types check the reference from here Google developer doc

提交回复
热议问题