Persisting a Collection class with ORMLite in android

前端 未结 2 416
傲寒
傲寒 2021-02-04 16:29

I have two classes setup like the following. I am confused as to when I need to annotate something as an foreign collection and when I do not. This may also sound silly, but n

2条回答
  •  南旧
    南旧 (楼主)
    2021-02-04 17:18

    If you want to save a Collection (such as an ArrayList) of objects to ORMLite the easiest way is this:

    @DatabaseField(dataType = DataType.SERIALIZABLE)
    private SerializedList myObjects;
    

    and to get my list of objects:

    public List getMyObjects() {
      return myObjects;
    }
    

提交回复
热议问题