title: Do I have to close realm on a per thread-basis, or per usage/class-basis?
body: <p>If I have a MainActivity like this:</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          // Set up database
          RealmConfiguration realmConfiguration = new RealmConfiguration.Builder(this).build();
          Realm.deleteRealm(realmConfiguration); // Clean slate
          Realm.setDefaultConfiguration(realmConfiguration); // Make this Realm the default
  
          realm = Realm.getDefaultInstance();
      }
  
      @Override
      public void onDestroy() {
          realm.close();
          super.onDestroy();
      }
  }
  </code></pre>
  
  <p>And I use <code>realm.getDefaultInstance()</code> in another class (same thread) like this:</p>
  
  <pre><code>public class ViewBookActivity extends Activity {
      private Realm realm;
  
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_scan_result);
  
          realm = Realm.getDefaultInstance();
      }
  }
  </code></pre>
  
  <p>Should I then call <code>realm.close()</code> in <code>onDestroy()</code> in <code>ViewBookActivity</code>? Or is it sufficient to close it in <code>MainActivity</code>?</p>
  
  <p>Realm documentation says:</p>
  
  <blockquote>
    <p>Realm instances are reference counted, which means that if you call
    getInstance() twice in a thread, you will also have to call close()
    twice as well.</p>
  </blockquote>
  
  <p>But I'm not sure if this applies to <code>getDefaultInstance()</code>.</p>
  
  <p>Also, is it OK to stick to <code>Realm.getDefaultInstance()</code>, even in other threads, if I close it when I'm done writing to it? I don't really understand the potential usage of <code>Realm.getInstance(Context context)</code>.</p>
  
  <p>Thanks</p>