Search code examples
androidrealmrealm-mobile-platformrealm-list

Realm database - field of type x is not supported


im working with realm in android and im getting this error message: error: Field "items" of type "java.util.List" is not supported.

it's at this line:

private List<Item> items;

here is the class:

public class Article extends RealmObject implements Serializable{

@PrimaryKey
private String category;
private List<Item> items;

public String getCategory() {
    return category;
}

public void setCategory(String category) {
    this.category = category;
}

public List<Item> getItems() {
    return items;
}

public void setItems(List<Item> items) {
    this.items = items;
}

}

can anybody help me?


Solution

  • Unfortunately RealmDatabase doesn’t support List<>. But you can achieve the same result by Using RealmList :)

    Realm supports subclasses of RealmObject and RealmList to model relationships.

    From: https://realm.io/docs/java/latest