Reputation: 368
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?
Upvotes: 8
Views: 5997
Reputation: 3866
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
Upvotes: 1
Reputation: 43384
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
Upvotes: 1