Hi, I have read your documentation about using different Realm instances in different threads and how the objects realmlist and realmresults cannot be shared between threads, this is a completely different issue...

I have a class called FBGroup which basically extends RealmObject and looks like this

I am first loading it from the internet in the background thread and then storing it to Realm in the main thread, loading takes place with the help of Gson, my bg task doInBackground looks like this

It just has one line of code to load straight from JSON and the FBUtil method call looks like this
The highlighted line 111 is giving me the error that says Realm cannot be used in the bg thread, i am simply storing json data into the FBGroup object

There is no sign of Realm.getInstance or anything of that sort anywhere, so what is going on? Thanks for your suggestions and time in advance, does this have something to do with the fact that ID is a primary key and Realm is actually trying to read the key or something? I have added the default constructor to the FBGroup class, its not pasted here though
UPDATE 1
The debugger says this...for the single line inside the AsyncTask

UPDATE 2
I fixed the error by doing this, I made a copy of the object FBGroup and passed the copy to the AsyncTask and it works perfectly

Though I ll be honest , I dont understand the reason behind this line fixing the error, the object FBGroup comes from an ArrayList that is loaded like this

The method in consideration loads a list of Group objects from Realm database like this

It seems there is a problem here, I want to load a number of objects from Realm into an ArrayList, I think I have made some mistake here, your clarification would solve the issue, thanks in advance, in the meantime, let me try searching some solutions on realm to arraylist :)
UPDATE 3
This other technique worked as well where I directly duplicate stuff from the RealmResults to ArrayList, is there no way to go Realmresults to ArrayList in a more optimal way, I read your issues and saw a guy asking the reverse from List to RealmResults thanks, for your suggestions in advance

Hi, I have read your documentation about using different Realm instances in different threads and how the objects realmlist and realmresults cannot be shared between threads, this is a completely different issue...

I have a class called FBGroup which basically extends RealmObject and looks like this

I am first loading it from the internet in the background thread and then storing it to Realm in the main thread, loading takes place with the help of Gson, my bg task doInBackground looks like this


It just has one line of code to load straight from JSON and the FBUtil method call looks like this
The highlighted line 111 is giving me the error that says Realm cannot be used in the bg thread, i am simply storing json data into the FBGroup object
There is no sign of Realm.getInstance or anything of that sort anywhere, so what is going on? Thanks for your suggestions and time in advance, does this have something to do with the fact that ID is a primary key and Realm is actually trying to read the key or something? I have added the default constructor to the FBGroup class, its not pasted here though
UPDATE 1

The debugger says this...for the single line inside the AsyncTask
UPDATE 2
I fixed the error by doing this, I made a copy of the object FBGroup and passed the copy to the AsyncTask and it works perfectly


Though I ll be honest , I dont understand the reason behind this line fixing the error, the object FBGroup comes from an ArrayList that is loaded like this
The method in consideration loads a list of Group objects from Realm database like this

It seems there is a problem here, I want to load a number of objects from Realm into an ArrayList, I think I have made some mistake here, your clarification would solve the issue, thanks in advance, in the meantime, let me try searching some solutions on realm to arraylist :)
UPDATE 3

This other technique worked as well where I directly duplicate stuff from the RealmResults to ArrayList, is there no way to go Realmresults to ArrayList in a more optimal way, I read your issues and saw a guy asking the reverse from List to RealmResults thanks, for your suggestions in advance