Skip to content Skip to sidebar Skip to footer

Realm Relation Field Always Null

There are my models: public class RChat extends RealmObject { @PrimaryKey private String Id; private RMyTest Test; public RChat() {} } and public cla

Solution 1:

The code looks correct. If you get null by examine the chat1's Test field in the debug window, you will get a null value. That is expected.

Realm will generate a proxy class and override the getters/setters in the proxy class. So if you try

RMyTestrProfile= chat1.getTest();

I am sure you can get the corresponding RMyTest Object instead of null.

This behaviour is documented here.

Solution 2:

I was thinking my objects must not be null directly but the point is Realm uses proxy for models and the proxy is not null actually.

Post a Comment for "Realm Relation Field Always Null"