Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

AddanIDwhilestoringdataintoRealmDatabase

I useed Relam to store my json for a while, but today I face a problem about id, (id of API and id_application).

my json :

"area_responsibility": {
        "id_api": 1,

        "name": "CASABLANCA",

        "code": "CASA"
        }

I look into doc of realm website, they said that UUID is the best way, so this my class :

@PrimaryKey
private String id_api;

private String title_area;
private String name;
private String code;
private int level;

so I add this line id_application = UUID.randomUUID().toString(); but it gives me error !

  @PrimaryKey
    private String id_application = UUID.randomUUID().toString();

    private String id_api;
    private String title_area;
    private String name;
    private String code;
    private int level;

So my question is : how to parse json and store it with my ids not ids of API ??

Comments