title: Realm access from incorrect thread Android
body: <p>I am dealing with this issue on Android :</p>
  
  <p>Realm access from incorrect thread. Realm objects can only be accessed on the thread they where created.</p>
  
  <p>I want to use Realm in my RemoteViewsFactory with </p>
  
  <pre><code>public class RemoteViewsX implements RemoteViewsFactory {
  
      public RemoteViews getViewAt(int paramInt) {
      if (this.results != null &amp;&amp; this.results.size() != 0 &amp;&amp; this.results.get(paramInt) != null) {
      //FAILED HERE
      }
  </code></pre>
  
  <p>}</p>
  
  <p>...
  This call failed! Why ?</p>
  
  <p>I fetch my data like this in my class:</p>
  
  <pre><code>public void onDataSetChanged() {
          Realm realm = Realm.getInstance(RemoteViewsX.this.ctx);
          this.results =  realm.where(Model.class).findAll();
  }
  </code></pre>
  
  <p>I called my remoteFactory like this :</p>
  
  <pre><code>public class ScrollWidgetService extends RemoteViewsService {
      @Override
      public RemoteViewsFactory onGetViewFactory(Intent intent) {
          return new RemoteViewsX (getApplicationContext());
      }
  }
  </code></pre>
  
  <p>Any idea ?</p>