Reputation: 3624
As we dont have any list data type in realm, how can we use ArrayList<String>
in a realm object?
I had same question for the arrayLists of the custom models we make i.e. ArrayList<CustomModel>
but for that I understand that we first have to make RealmObject of same Custom model using
public class CustomObject extends RealmObject {
private String name;
private String age;
}
and then I can use
private RealmList<CustomObject> customObjectList;
in another RealmObject
Do i have to do same with arrayList of string?
1. Making String object
2. Use that object in Realm List
Upvotes: 16
Views: 18434
Reputation: 178
Now it is possible to work with RealmList where T can be the following types: String, Integer, Boolean, Float, Double, Short, Long, Byte, byte[] and Date` (according to the official docs https://realm.io/docs/java/latest/#relationships, see Relationships -> List of Primitives)
For example:
public RealmList<String> telephoneNumbers = new RealmList<>();
Upvotes: 5
Reputation: 8138
Yes, you have to manually box your strings in a StringObject. We'd like to add support for RealmList<String>
, RealmList<Integer>
, etc., but it's a long way out.
Upvotes: 17