Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android RealmList<Integer> and RealmList<String>

I'm working with Realm to create my android app's ORM with Realm. The problem is that when I try to create an object like this:

public class Airport extends RealmObject {
    private int Id;
    private String Name;
    private String Code;
    private RealmList<Integer> destinations;
}

androidStudio tells me that I can't have the RealmList with type Integer; and for String type either. I've been looking a few similar questions, but the best approach is to declare an object like:

public class MyRealmInteger extends RealmObject {
    private int destination;
}

so this way I can rewrite my class as follows:

public class Airport extends RealmObject {
    private int Id;
    private String Name;
    private String Code;
    private RealmList<MyRealmInteger> destinations;
}

but I think it's a very complicated. There isn't any other easier solution?

like image 625
MJB22 Avatar asked Jun 23 '16 11:06

MJB22


2 Answers

but I think it's a very complicated. There isn't any other easier solution?

No there is not. Not yet at least. They're "working on it":

This feature is among a handfull of top features that we hope to take on next. We will however give the current 1.0 a bit of peace to ensure stability before we push a lot of new features.

You can check this issue for updates on it https://github.com/realm/realm-java/issues/575

like image 185
Tim Avatar answered Nov 04 '22 15:11

Tim


Please take a look at this answer https://stackoverflow.com/a/46576569/3479489 realm will add support for primitives in the version 4.0.0

like image 44
Yayo Arellano Avatar answered Nov 04 '22 13:11

Yayo Arellano