Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6618523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:50:42+00:00 2026-05-25T20:50:42+00:00

I am getting errors to do with this coding below. I know it is

  • 0

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:

MySimpleCursorTreeAdapter mscta = new MySimpleCursorTreeAdapter(

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;
            }
    }

Stacktrace:

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.<init>(SimpleCursorTreeAdapter.java:157)
09-11 14:33:10.565: ERROR/AndroidRuntime(161):     at com.browse.max.Categories$MySimpleCursorTreeAdapter.<init>(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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:50:43+00:00Added an answer on May 25, 2026 at 8:50 pm

    If the exception is really being thrown at the line that you indicated, then the cause is that R.id is null.

    The other possibilities are that R is null or R.layout is null. But if either of those were true, then an NPE would have been thrown by:

        setContentView(R.layout.cattest);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After I installed Aptana (install directory: /usr/share/aptana ) I keep getting errors like this:
MessageBox.Show((some_string.Length).ToString); I am getting two errors for this: The best overloaded method match for
Linux GCC 4.4.2 I am doing some socket programming. However, I keep getting this
I'm doing some maintenance coding on a webapp and I am getting a javascript
I am getting this below error when I try to update a row in
Getting this error: 2009-09-03 12:44:02.307 xcodebuild[307:10b] warning: compiler 'com.apple.compilers.llvm.clang.1_0.analyzer' is based on missing compiler
Getting this error with jquery & jquery.form. Site has been live for awhile..upgraded to
Anyone getting this error when using the new free chart controls MS bought from
I´m getting this error while trying to commit to a svn repository: svn: MKACTIVITY
Keep getting this error after inserting a subdatasheet into a query and trying to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.