I am using realm with gson. I have a modal which has a list of int type field. Realm does not support currently list of primitives. To solve this there is a solution. I created my RealmInt class.
import io.realm.RealmObject;
public class RealmInt extends RealmObject {
private int val;
public int getVal() {
return val;
}
public void setVal(int val) {
this.val = val;
}
}
I have a big modal object something like that..
public class Product extends RealmObject {
@PrimaryKey
private int productID;
private int priority;
private boolean isFavourite;
.....
.....
.....
private RealmList<Document> documents;
private RealmList<ProductInfoGroup> productInfoGroups;
private RealmList<RealmInt> categories;
I must deserialize the json array below to Product modals.
[{
"productID": 776,
"categories": [
35
],
"name": "",
"priority": 3,
......
"status": 2,
"documents": [
{
"documentID": 74,
"productID": 776,
"name": null,
....
"isDefault": true
}
],
"productInfoGroups": [
{
"productInfoGroupID": 1575,
"productID": 776,
.....
"productInfos": [
{
"productInfoID": 2707,
"productInfoGroupID": 1575,
"title": "",
...
},
{
"productInfoID": 2708,
"productInfoGroupID": 1575,
...
},
{
"productInfoID": 2709,
.....
}
]
}
],
"lastUpdateDate": 130644319676570000,
"isActive": true
},....]
There is a solution here but it is not for big objects. I need to change only categories array and other deserialization must be done by default gson deserialization.