This question already has an answer here:
- Cannot retrieve field values from realm object, values are null in debugger 3 answers
There are my models:
public class RChat extends RealmObject {
@PrimaryKey
private String Id;
private RMyTest Test;
public RChat() {}
}
and
public class RMyTest extends RealmObject {
@PrimaryKey
private String myName;
public RMyTest() {
}
}
And I'm using like this:
mRealm = Realm.getInstance(this);
mRealm.beginTransaction();
final RChat chat = mRealm.createObject(RChat.class);
chat.setId("test");
RMyTest rProfile = mRealm.createObject(RMyTest.class);
rProfile.setMyName("alireza test");
chat.setTest(rProfile);
//mRealm.copyToRealmOrUpdate(chat);
mRealm.commitTransaction();
RChat chat1 = mRealm.where(RChat.class).equalTo("Id","test").findFirst();
but the chat1
object's Test
field has null value always. How can I fix this problem?