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:
private class SQLiteCursorLoader extends AsyncTaskLoader<Cursor> {
private String _queryString;
private SQLiteDatabase _db;
...
public SQLiteCursorLoader(Context context, String queryString) {
super(context);
_queryString = queryString;
_db = MySQLiteOpenHelper.getWritableDatabase();
}
....
}
But where do I close the connection again?