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 6550311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:12:02+00:00 2026-05-25T12:12:02+00:00

can anyone tell wats wrong in this code… I put code bellow. mySQLiteAdapter =

  • 0

can anyone tell wats wrong in this code… I put code bellow.

mySQLiteAdapter = new SQLiteAdapter(this);
    cursor = mySQLiteAdapter.displayCategory();
    startManagingCursor(cursor);

    String[] from = new String[] { SQLiteAdapter.KEY_ID, SQLiteAdapter.KEY_CATEGORY };

    int[] to = new int[] { android.R.id.text1 };

    mCategory = (Spinner) findViewById(R.id.choose_category);
    SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
            android.R.layout.simple_spinner_item, cursor, from, to);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mCategory.setAdapter(adapter);

MyAdapter class having following code

public Cursor displayCategory() {
        String[] columns = new String[]{KEY_ID, KEY_CATEGORY};          
        Cursor cursor = sqLiteDatabase.query(MYCATEGORY_TABLE, columns, 
                null, null, null, null, null);

        return cursor;

Null pointer Exception. How to avoid it.
This is the error on log cat

 09-09 15:49:16.535: ERROR/AndroidRuntime(6526): Uncaught handler: thread main exiting  due to uncaught exception
09-09 15:49:16.545: ERROR/AndroidRuntime(6526): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.mpt.receiptor/com.android.mpt.receiptor.SearchReceipt}: java.lang.NullPointerException
09-09 15:49:16.545: ERROR/AndroidRuntime(6526):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
09-09 15:49:16.545: ERROR/AndroidRuntime(6526):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
09-09 15:49:16.545: ERROR/AndroidRuntime(6526):     at android.app.ActivityThread.access$2200(ActivityThread.java:119)
09-09 15:49:16.545: ERROR/AndroidRuntime(6526):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
09-09 15:49:16.545: ERROR/AndroidRuntime(6526):     at android.os.Handler.dispatchMessage(Handler.java:99)
09-09 15:49:16.545: ERROR/AndroidRuntime(6526):     at android.os.Looper.loop(Looper.java:123)
09-09 15:49:16.545: ERROR/AndroidRuntime(6526):     at android.app.ActivityThread.main(ActivityThread.java:4363)
09-09 15:49:16.545: ERROR/AndroidRuntime(6526):     at java.lang.reflect.Method.invokeNative(Native Method)
09-09 15:49:16.545: ERROR/AndroidRuntime(6526):     at java.lang.reflect.Method.invoke(Method.java:521)
09-09 15:49:16.545: ERROR/AndroidRuntime(6526):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
09-09 15:49:16.545: ERROR/AndroidRuntime(6526):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
09-09 15:49:16.545: ERROR/AndroidRuntime(6526):     at dalvik.system.NativeStart.main(Native Method)
09-09 15:49:16.545: ERROR/AndroidRuntime(6526): Caused by: java.lang.NullPointerException
09-09 15:49:16.545: ERROR/AndroidRuntime(6526):     at com.android.mpt.receiptor.SQLiteAdapter.displayCategory(SQLiteAdapter.java:135)
09-09 15:49:16.545: ERROR/AndroidRuntime(6526):     at com.android.mpt.receiptor.SearchReceipt.onCreate(SearchReceipt.java:96)
09-09 15:49:16.545: ERROR/AndroidRuntime(6526):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
09-09 15:49:16.545: ERROR/AndroidRuntime(6526):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)

Pls someone help me.

Thanks in advance

  • 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-25T12:12:03+00:00Added an answer on May 25, 2026 at 12:12 pm

    It looks like in this line:

    Cursor cursor = sqLiteDatabase.query(MYCATEGORY_TABLE, columns,  
                null, null, null, null, null); 
    

    that sqLiteDatabase is null – make sure it is initialised in your onCreate method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone tell me what's wrong in this code: #!/usr/local/bin/python import os import string,
Can anyone tell me what I a doing wrong with this code? I am
Can anyone tell me what exactly does this Java code do? SecureRandom random =
Can anyone tell me what is wrong with this? I'm getting a syntax error
Can anyone tell me what is wrong with this? The file is renamed using
Can anyone tell me why this code generates queue after starting the threads? Basically,
Can anyone tell me why this code is returning undefined . I was hoping
Can anyone tell me what's wrong with this robots.txt? http://bizup.cloudapp.net/robots.txt The following is the
can anyone tell me why this doesn't work? db = openOrCreateDatabase(database.db, SQLiteDatabase.CREATE_IF_NECESSARY, null); db.setLocale(Locale.getDefault());
can anyone tell me the function of following code. is the code line NSString*

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.