Raghul Sugathan Raghul Sugathan -4 years ago 222
Android Question

RealM unable to save data with Nested Classes

I am using RealM for my project and unable to save a class with nested classes inside it. I am getting the following error in android studio.

RealmClass annotation does not support nested classes


here is what I am doing :

public class Test extends RealmObject {

@SerializedName("1")
@Expose
private Leave leave;
@SerializedName("2")
@Expose
private Today today;
@SerializedName("3")
@Expose
private Vehicle cab;
@SerializedName("4")


Gradle version of Realm is as follows :

compile files('libs/realm-android-0.84.2.jar')


Any help is will be very useful for me.

Answer Source

You need to create your RealmModel's as standalone classes. Inner classes is not supported yet.
@RealmClass annotation is used, if your class can't extend of RealmObject. In this case your class also need to implement RealmModel interface.

Read more in documentation

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download