java.lang.IllegalArgumentException: Object not managed by Realm, so it cannot be removed
See original GitHub issueI’m trying to delete Object from realm, but first time, I try to delete it, the application crashes, but then I reopen the application and try to delete, it is deleted. (doing this is recycler view)
realm.executeTransaction(new Realm.Transaction() {
@Override
public void execute(Realm realm) {
NotesPOJO note = notes.get(key);
note.deleteFromRealm(); //this is the line which shows the error
}
});
For second attempt for item of recycler view, its deleting but for the first attempt the application is crashing.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Realm Exception 'value' is not a valid managed object
Solution 1 - Pass the unique identifer, then query the realm object: int uniqueId = Parcels.unwrap(data.getParcelableExtra("uniqueId"));.
Read more >io.realm.RealmObject.isValid java code examples - Tabnine
Checks if the RealmObject is still valid to use i.e. the RealmObject hasn't been deleted nor has the io.realm.Realm been closed. It will...
Read more >RealmObject (Realm 3.5.0) - MongoDB
Managed objects are thread confined so that they cannot be accessed from other threads than the one that created them. If this method...
Read more >Create reactive mobile apps in a fraction of the time - Realm
public class Person extends RealmObject { @Required // Name is not ... object is managed by Realm, so any further changes to the...
Read more >Fix list for IBM WebSphere Application Server V8.5
IT31238, MQ classes for Java application cannot get NameValueData from RFH2 when ... PH40532, OIDC TAI might not remove OAuth access token cache...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

That’s simple, it’s because
notesis some kind of map, not a RealmResults or anything, and theNotesPOJOyou’re storing inside it is not a managed RealmObject (was not obtained by querying Realm).To delete an object from the Realm, the object you call
deleteFromRealm()on has to be managed, aka it must be obtained from aRealmResults.nah that just means you probably never stored it in the Realm.
https://github.com/Zhuinden/rx-realm-recyclerview-experiment/blob/a5a1bcbecf24203ea2973d6a9223825aa7aa1aff/app/src/main/java/com/zhuinden/rxrealm/path/cat/CatAdapter.java#L18