Android Null Pointer Exception MySimpleTreeAdapter
<p>I am getting errors to do with this coding below. I know it is a mess of a way to go around things. For some reason I am getting a Null Pointer Exception. The stack trace points to line 44 which is this line:</p>

<pre><code>MySimpleCursorTreeAdapter mscta = new MySimpleCursorTreeAdapter(
</code></pre>

<p>Code:</p>

<pre><code>    protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.cattest);

            SQLiteDatabase checkDB = null;
            String myPath = DB_PATH + DB_NAME;
            checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY);
            //froggydb = dbHelper.getReadableDatabase();


            Cursor groupCursor = checkDB.rawQuery("SELECT * FROM questions", null);
            MySimpleCursorTreeAdapter mscta = new MySimpleCursorTreeAdapter(
                                                    this,
                                                    groupCursor,
                                                    R.layout.employee_list_item,
                                                    new String[] {"question"},
                                                    new int[] {R.id.firstName},
                                                    R.layout.employee_list_item,
                                                    new String[] {"question"},
                                                    new int[] {R.id.firstName});
            setListAdapter(mscta);
            checkDB.close();
    }

    class MySimpleCursorTreeAdapter extends SimpleCursorTreeAdapter{

            public MySimpleCursorTreeAdapter(Context context, Cursor cursor,
                            int groupLayout, String[] groupFrom, int[] groupTo,
                            int childLayout, String[] childFrom, int[] childTo) {
                    super(context, cursor, groupLayout, groupFrom, groupTo, childLayout, childFrom,
                                    childTo);
            }


            @Override
            protected Cursor getChildrenCursor(Cursor groupCursor) {
                    String countryID = Integer.toString(groupCursor.getInt(0));
                    SQLiteDatabase checkDB = null;
                    String myPath = DB_PATH + DB_NAME;
                    checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY);

                    Cursor value = checkDB.rawQuery("SELECT * FROM questions", null);

                    String test = "";
                    if(value.moveToFirst())
                            test =  value.getInt(0) + ": " + value.getString(1);
                    while(value.moveToNext()){
                            test += ";" + value.getInt(0) + ": " + value.getString(1);
                    }
                    return value;
            }
    }
</code></pre>

<p>Stacktrace:</p>

<pre><code>09-11 14:33:09.365: ERROR/AndroidRuntime(161): Uncaught handler: thread main exiting due to uncaught exception
09-11 14:33:10.565: ERROR/AndroidRuntime(161): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.home.max/com.browse.max.Categories}: java.lang.NullPointerException
09-11 14:33:10.565: ERROR/AndroidRuntime(161):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2401)
09-11 14:33:10.565: ERROR/AndroidRuntime(161):     at android.app.ActivityThread.startActivityNow(ActivityThread.java:2242)
09-11 14:33:10.565: ERROR/AndroidRuntime(161):     at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:127)
09-11 14:33:10.565: ERROR/AndroidRuntime(161):     at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:339)
09-11 14:33:10.565: ERROR/AndroidRuntime(161):     at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:631)
09-11 14:33:10.565: ERROR/AndroidRuntime(161):     at android.widget.TabHost.setCurrentTab(TabHost.java:317)
09-11 14:33:10.565: ERROR/AndroidRuntime(161):     at android.widget.TabHost$2.onTabSelectionChanged(TabHost.java:127)
09-11 14:33:10.565: ERROR/AndroidRuntime(161):     at android.widget.TabWidget$TabClickListener.onClick(TabWidget.java:346)
09-11 14:33:10.565: ERROR/AndroidRuntime(161):     at android.view.View.performClick(View.java:2344)
09-11 14:33:10.565: ERROR/AndroidRuntime(161):     at android.view.View.onTouchEvent(View.java:4133)
09-11 14:33:10.565: ERROR/AndroidRuntime(161):     at android.view.View.dispatchTouchEvent(View.java:3672)
09-11 14:33:10.565: ERROR/AndroidRuntime(161):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:850)
09-11 14:33:10.565: ERROR/AndroidRuntime(161):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882)
09-11 14:33:10.565: ERROR/AndroidRuntime(161):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882)
09-11 14:33:10.565: ERROR/AndroidRuntime(161):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882)
09-11 14:33:10.565: ERROR/AndroidRuntime(161):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882)
09-11 14:33:10.565: ERROR/AndroidRuntime(161):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882)
09-11 14:33:10.565: ERROR/AndroidRuntime(161):     at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1712)
09-11 14:33:10.565: ERROR/AndroidRuntime(161):     at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1202)
09-11 14:33:10.565: ERROR/AndroidRuntime(161):     at android.app.Activity.dispatchTouchEvent(Activity.java:1987)
09-11 14:33:10.565: ERROR/AndroidRuntime(161):     at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1696)
09-11 14:33:10.565: ERROR/AndroidRuntime(161):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1658)
09-11 14:33:10.565: ERROR/AndroidRuntime(161):     at android.os.Handler.dispatchMessage(Handler.java:99)
09-11 14:33:10.565: ERROR/AndroidRuntime(161):     at android.os.Looper.loop(Looper.java:123)
09-11 14:33:10.565: ERROR/AndroidRuntime(161):     at android.app.ActivityThread.main(ActivityThread.java:4203)
09-11 14:33:10.565: ERROR/AndroidRuntime(161):     at java.lang.reflect.Method.invokeNative(Native Method)
09-11 14:33:10.565: ERROR/AndroidRuntime(161):     at java.lang.reflect.Method.invoke(Method.java:521)
09-11 14:33:10.565: ERROR/AndroidRuntime(161):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
09-11 14:33:10.565: ERROR/AndroidRuntime(161):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
09-11 14:33:10.565: ERROR/AndroidRuntime(161):     at dalvik.system.NativeStart.main(Native Method)
09-11 14:33:10.565: ERROR/AndroidRuntime(161): Caused by: java.lang.NullPointerException
09-11 14:33:10.565: ERROR/AndroidRuntime(161):     at com.browse.max.Categories$MySimpleCursorTreeAdapter.getChildrenCursor(Categories.java:69)
09-11 14:33:10.565: ERROR/AndroidRuntime(161):     at android.widget.CursorTreeAdapter.getChildrenCursorHelper(CursorTreeAdapter.java:106)
09-11 14:33:10.565: ERROR/AndroidRuntime(161):     at android.widget.SimpleCursorTreeAdapter.init(SimpleCursorTreeAdapter.java:172)
09-11 14:33:10.565: ERROR/AndroidRuntime(161):     at android.widget.SimpleCursorTreeAdapter.&lt;init&gt;(SimpleCursorTreeAdapter.java:157)
09-11 14:33:10.565: ERROR/AndroidRuntime(161):     at com.browse.max.Categories$MySimpleCursorTreeAdapter.&lt;init&gt;(Categories.java:62)
09-11 14:33:10.565: ERROR/AndroidRuntime(161):     at com.browse.max.Categories.onCreate(Categories.java:44)
09-11 14:33:10.565: ERROR/AndroidRuntime(161):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
09-11 14:33:10.565: ERROR/AndroidRuntime(161):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364)
09-11 14:33:10.565: ERROR/AndroidRuntime(161):     ... 29 more
</code></pre>
