Simo Simo - 2 months ago 20
Android Question

List<String> as a @ForeignCollectionField ormlite

I have in my model Class

List<String> _photo_array;


since I can put anotation on String Class is it a way to persist it using ormLite?

Answer

since I can put anotation on String Class is it a way to persist it using ormLite?

You are going to have to create an entity that wraps the String. Something like:

 @DatabaseTable
 public class Photo {
     @DatabaseField(generatedId = true)
     private int id;
     @DatabaseField
     private String photo;
     @DatabaseField(foreign = true)
     private Model model;
 }

Then your model class would have a ForeignCollection of these photos.

 @DatabaseTable
 public class Model {
     @DatabaseField(generatedId = true)
     private int id;
     @ForeignCollectionField()
     private ForeignCollection<Photo> photos;
 }

See the foreign collection example.

Comments