{"action":"created","issue":{"url":"https://api.github.com/repos/realm/realm-java/issues/3942","repository_url":"https://api.github.com/repos/realm/realm-java","labels_url":"https://api.github.com/repos/realm/realm-java/issues/3942/labels{/name}","comments_url":"https://api.github.com/repos/realm/realm-java/issues/3942/comments","events_url":"https://api.github.com/repos/realm/realm-java/issues/3942/events","html_url":"https://github.com/realm/realm-java/issues/3942","id":197366062,"number":3942,"title":"java.lang.IllegalStateException: Mutable method call during read transaction.","user":{"login":"vranacse","id":19587413,"avatar_url":"https://avatars.githubusercontent.com/u/19587413?v=3","gravatar_id":"","url":"https://api.github.com/users/vranacse","html_url":"https://github.com/vranacse","followers_url":"https://api.github.com/users/vranacse/followers","following_url":"https://api.github.com/users/vranacse/following{/other_user}","gists_url":"https://api.github.com/users/vranacse/gists{/gist_id}","starred_url":"https://api.github.com/users/vranacse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vranacse/subscriptions","organizations_url":"https://api.github.com/users/vranacse/orgs","repos_url":"https://api.github.com/users/vranacse/repos","events_url":"https://api.github.com/users/vranacse/events{/privacy}","received_events_url":"https://api.github.com/users/vranacse/received_events","type":"User","site_admin":false},"labels":[{"id":3545600,"url":"https://api.github.com/repos/realm/realm-java/labels/T:Help","name":"T:Help","color":"cc317c","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2016-12-23T13:02:47Z","updated_at":"2016-12-23T14:04:51Z","closed_at":null,"body":"> We LOVE to help with any issues or bug you have!\r\n\r\n> **Questions**: Hey I just want to delete some entries from the already queried from Realm. But i am getting this exception \r\n\r\n> **Feature Request**:IT should be simmple to delete or remove just from queried data but not from the realm itself\r\n\r\n> **Bugs**: See this\r\n>\r\n>\r\n>\r\n> \r\n\r\n#### Goal\r\n\r\n> Just see and give the appropriate solution for this\r\n\r\n#### Expected Results\r\n\r\n> should be removed from the list\r\n\r\n#### Actual Results\r\n\r\n>    java.lang.IllegalStateException: Mutable method call during read transaction.\r\n                                                                                at io.realm.internal.TableView.throwImmutable(TableView.java:944)\r\n                                                                                at io.realm.internal.TableView.remove(TableView.java:566)\r\n                                                                                at io.realm.RealmResults.remove(RealmResults.java:464)\r\n\r\n#### Steps & Code to Reproduce\r\n\r\n> Describe your current debugging efforts.\r\n\r\n#### Code Sample\r\n\r\n```java\r\n\r\n> for (int i = 0; i < RealmContractItemList.size(); i++) {\r\n            if (RealmContractItemList.get(i).getID().equalsIgnoreCase(key)) {\r\n                Log.e(TAG,RealmContractItem.get(i).getID());\r\n                RealmContractItemList.remove(i);\r\n            }\r\n        }\r\n> \r\n\r\n```\r\n\r\n#### Version of Realm and tooling\r\nRealm version(s): ?\r\n\r\nRealm sync feature enabled: yes/no\r\n\r\nAndroid Studio version: ?\r\n\r\nWhich Android version and device: ?\r\n"},"comment":{"url":"https://api.github.com/repos/realm/realm-java/issues/comments/268994574","html_url":"https://github.com/realm/realm-java/issues/3942#issuecomment-268994574","issue_url":"https://api.github.com/repos/realm/realm-java/issues/3942","id":268994574,"user":{"login":"vranacse","id":19587413,"avatar_url":"https://avatars.githubusercontent.com/u/19587413?v=3","gravatar_id":"","url":"https://api.github.com/users/vranacse","html_url":"https://github.com/vranacse","followers_url":"https://api.github.com/users/vranacse/followers","following_url":"https://api.github.com/users/vranacse/following{/other_user}","gists_url":"https://api.github.com/users/vranacse/gists{/gist_id}","starred_url":"https://api.github.com/users/vranacse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vranacse/subscriptions","organizations_url":"https://api.github.com/users/vranacse/orgs","repos_url":"https://api.github.com/users/vranacse/repos","events_url":"https://api.github.com/users/vranacse/events{/privacy}","received_events_url":"https://api.github.com/users/vranacse/received_events","type":"User","site_admin":false},"created_at":"2016-12-23T14:04:50Z","updated_at":"2016-12-23T14:04:50Z","body":"Yeah that good but still not a good way to process the data\n\nOn 23-Dec-2016 7:30 PM, \"Gabor Varadi\" <notifications@github.com> wrote:\n\n@vranacse <https://github.com/vranacse> RealmResults is a Cursor (in the\nform of a list) to the underlying database, it contains a list of pointers\nto the elements that satisfy the query conditions. You cannot mutate the\n\"result set returned for those given conditions\", unless you mutate the\nunderlying data. This is to always obtain a consistent view of the result\nset - after all, if you arbitrarily remove an element from that results,\nbut you also commit a write transaction that updates the result set, then\nwho will keep track of which element shouldn't be evaluated by the Realm\nCore?\n\nrealmResults.remove() wouldn't even be allowed, you are using an outdated\nversion of Realm. I'm not sure which, it's definitely something before\n0.89.0.\n\nYou have two hacky workarounds:\n\n1.)\n\nList<E> list = new ArrayList<>();\nlist.addAll(realmResults);\n\n2.)\n\nList<E> list = realm.copyFromRealm(realmResults);\n\n—\nYou are receiving this because you were mentioned.\n\nReply to this email directly, view it on GitHub\n<https://github.com/realm/realm-java/issues/3942#issuecomment-268994021>,\nor mute the thread\n<https://github.com/notifications/unsubscribe-auth/ASrhVf_aVuTbR5ZOldC_gCYcMhZIa-cMks5rK9QMgaJpZM4LUzgS>\n.\n"}}
{"actor":{"display_login":"vranacse"}}