insert to realm from json without primary key

521 views Asked by At

I have a big JSONArray like this

 [{
     "serverId":1,"title":"title!"
 },....]

and I have an object:

 class A extends RealmObject{
    @PrimaryKey
    public int local_id;

    public int serverId;

    public String title;

 }      

and I want to add JSON to the realm like this:

 realm.createOrUpdateAllFromJson(A.class,JSONarray);      

but as you can see there is no local_id in JSON and realm cannot add JSON without PrimaryKey, So is there a way to add my JSON without changing it?
and local_id is just an auto increment column.

0

There are 0 answers