Problems using SQLiteOpenHelper, returns null on create, possible Thread issue
<p>I have a ContentProvider named <em>GeneralDataProvider</em>. Which calls </p>

<pre><code>@Override
public boolean onCreate() {
    mDatabaseOpenHelper = new DatabaseOpenHelper(getContext());
    return true;
}
</code></pre>

<p>Which looks like:</p>

<pre><code>private static class DatabaseOpenHelper extends SQLiteOpenHelper {
    DatabaseOpenHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        Log.e("DataBaseOpenHelper", "onCreate()");
        //The columns we'll include in the dictionary table
        //db.execSQL("CREATE TABLE general " + 
        // .. and more
    }
}
</code></pre>

<p><strong>The problem</strong></p>

<p>This works fine as long as I run managedQuery(...) inside an Activity, but when i try to execute the following code in a thread, I get a NullPointerException.</p>

<pre><code> public class SyncManager extends Thread {

         @Override
         public void run() {
            mIntent = new Intent();
            mIntent.setData(GeneralDataColumns.CONTENT_URI);
            GeneralDataProvider generalProvider = new GeneralDataProvider();
            mCursor = generalProvider.query(mIntent.getData(), GENERAL_PROJECTION, selection, null,
            GeneralDataColumns.DEFAULT_SORT_ORDER);
     }
 }
</code></pre>

<p>Which is executed from my main activity as such</p>

<pre><code>    mSyncManager = new SyncManager();
    mSyncManager.start();
</code></pre>

<p>After digging deeper, it turns out that what causes the NullPointerException is the following line, inside GeneralDataProvider.query().</p>

<pre><code>       SQLiteDatabase db = mDatabaseOpenHelper.getReadableDatabase();
</code></pre>

<p>Since mDatabaseOpenHelper is null.</p>

<p>Am I using my ContentProvider in an incorrect manner?</p>

<p>What I have tried:
Added 'synchronized' to the query()-method inside my GeneralDataProvider</p>
