Hello. Would you be so kind to help me update attached model. The example of the code is attached below. Again and again I see the one mistake and nothing can avoid it including suggested solution
public void setMessage(final Message message) {
mRealm.beginTransaction();
mRealm.copyToRealmOrUpdate(message);
mRealm.commitTransaction();
mRealm.beginTransaction();
Chat chat = getChat(message.getApplicant());
chat.setLast_message(message);
mRealm.copyToRealmOrUpdate(chat);
mRealm.commitTransaction();
}
Can't you do that in ONE transaction?
Anyways, the issue is that your message
remains unmanaged because you didn't do message = mRealm.copyToRealmOrUpdate(message)
.
Thx a lot!
@Zhuinden Thanks a again!
Most helpful comment
Can't you do that in ONE transaction?
Anyways, the issue is that your
message
remains unmanaged because you didn't domessage = mRealm.copyToRealmOrUpdate(message)
.