title: How should a SQLiteDatabase connection be handled inside an AsyncTaskLoader?
body: <p>I wondering where and when I should open/close my SQLiteDatabase connection in my AsyncTaskLoader. I don't feel like i fully understand the lifecycle of a Loader, so I'm afraid  that I might run into some memory leaks/NullPointerExceptions if I don't to this right. I currently open up my SQLiteDatabase in the constructor of my loader:</p>
  
  <pre><code>private class SQLiteCursorLoader extends AsyncTaskLoader&lt;Cursor&gt; {
  
      private String _queryString;
      private SQLiteDatabase _db;
      ...
  
      public SQLiteCursorLoader(Context context, String queryString) {
          super(context);
          _queryString = queryString;
          _db = MySQLiteOpenHelper.getWritableDatabase();
      }
  
      ....
  
  }
  </code></pre>
  
  <p>But where do I close the connection again?</p>