How store List<Integer> in ORMLite database

83 views
Skip to first unread message

Андрей Попко

unread,
Feb 23, 2017, 7:46:58 AM2/23/17
to ORMLite Android Users

I have next requirement.
I have some model which I parse using Gson. I want to use the same model to store data in ORMLite database. I can't use foreign collection in this situation, because so I should create different fields for parsing and database. And I should create extra entities for every new field with List.

What is the best solution in my situation?


public class Model {
    @SerializedName("listInteger")
    @Expose
    private List<Integer> listInteger;
}



Vlad

unread,
May 3, 2018, 8:20:10 AM5/3/18
to ORMLite Android Users
Hi,

use custom Persister class and implement your own serialization.


public class Model {
    @SerializedName("listInteger")
    @Expose
    @DatabaseField(persisterClass = MyDatePersister.class)
private List<Integer> listInteger; }



Dne čtvrtek 23. února 2017 13:46:58 UTC+1 Андрей Попко napsal(a):
Reply all
Reply to author
Forward
0 new messages