Can't open SQLite database
<p>I'm trying to pen my SQLite db with:</p>

<pre><code>dbHelper = new DataBaseHelper(context);
public static void open() throws SQLException {
    try {
        database = dbHelper.getWritableDatabase();
    } catch (Exception e) {
        e.printStackTrace();
        Log.d(Tag.getTag("open()"), "Can't open db");
    }
}
</code></pre>

<p>But it gives <code>NullPointerException</code>. Following is my <code>DataBaseHelper</code> class.</p>

<pre><code>//declarations and stuff

public DataBaseHelper(Context context) {
    super(context, VFS_DATABASE_NAME, null, DATABASE_VERSION);
    this.context = context;
}

@Override
public void onCreate(SQLiteDatabase db) {
    // TODO Auto-generated method stub
    Toast.makeText(context, "Creating DataBase for first time...", 2000).show();
    db.execSQL(DATABASE_CREATE);

}

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    Log.w(DataBaseHelper.class.getName(),
            "Upgrading database from version " + oldVersion + " to "
                    + newVersion + ", which will destroy all old data");
    db.execSQL("DROP TABLE IF EXISTS" + VFS_DATABASE_TABLE);
    onCreate(db);

}
</code></pre>

<p>I can't figure out what I'm doing wrong. Why is this error happening?</p>

<p><strong>Stack trace:</strong></p>

<pre><code>02-27 23:16:07.698: W/System.err(4685): java.lang.NullPointerException
02-27 23:16:07.698: W/System.err(4685):     at com.manager.boot.r1223.VSDataSource.open(VSDataSource.java:34)
02-27 23:16:07.698: W/System.err(4685):     at com.manager.boot.r1223.VSDataSource.ScanVirtualSystems(VSDataSource.java:52)
02-27 23:16:07.706: W/System.err(4685):     at com.manager.boot.r1223.OSListActivity.onCreate(OSListActivity.java:49)
02-27 23:16:07.706: W/System.err(4685):     at android.app.Activity.performCreate(Activity.java:4465)
02-27 23:16:07.706: W/System.err(4685):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
02-27 23:16:07.706: W/System.err(4685):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
02-27 23:16:07.706: W/System.err(4685):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
02-27 23:16:07.706: W/System.err(4685):     at android.app.ActivityThread.access$600(ActivityThread.java:123)
02-27 23:16:07.706: W/System.err(4685):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
02-27 23:16:07.706: W/System.err(4685):     at android.os.Handler.dispatchMessage(Handler.java:99)
02-27 23:16:07.706: W/System.err(4685):     at android.os.Looper.loop(Looper.java:137)
02-27 23:16:07.706: W/System.err(4685):     at android.app.ActivityThread.main(ActivityThread.java:4424)
02-27 23:16:07.706: W/System.err(4685):     at java.lang.reflect.Method.invokeNative(Native Method)
02-27 23:16:07.706: W/System.err(4685):     at java.lang.reflect.Method.invoke(Method.java:511)
02-27 23:16:07.706: W/System.err(4685):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
02-27 23:16:07.706: W/System.err(4685):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
02-27 23:16:07.706: W/System.err(4685):     at dalvik.system.NativeStart.main(Native Method)
</code></pre>
