我的模型类中有
List<String> _photo_array;
因为我可以在 String 类上添加注释,是否可以使用 ormLite 来持久化它?
最佳答案
since I can put anotation on String Class is it a way to persist it using ormLite?
您将必须创建一个包装 String
的实体。像这样的东西:
@DatabaseTable
public class Photo {
@DatabaseField(generatedId = true)
private int id;
@DatabaseField
private String photo;
@DatabaseField(foreign = true)
private Model model;
}
然后您的模型类将有这些照片的 ForeignCollection
。
@DatabaseTable
public class Model {
@DatabaseField(generatedId = true)
private int id;
@ForeignCollectionField()
private ForeignCollection<Photo> photos;
}
关于android - List<String> 作为@ForeignCollectionField ormlite,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20349587/