Search code examples
javaandroidrealmrealm-list

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?


Solution

  • 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