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

  • Home
  • SEARCH
  • 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 7633115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:47:39+00:00 2026-05-31T06:47:39+00:00

I have read through many sites and tutorials and have been unable to solve

  • 0

I have read through many sites and tutorials and have been unable to solve my problem. I have an application that works until I try to read from my database (it opens it just fine). I know its not the right way to do things but I have two global strings that I pass from my main activity to my DataBaseHelper class (DB_TABLE and spinnerPipeLengthText). When I call the following line of code to retrieve the data from all the columns in a specific row my application crashes.

Cursor cursorData = myDataBase.query(CSSTPipeSizingActivity.DB_TABLE, null, 
            CSSTPipeSizingActivity.spinnerPipeLengthText, null, null, null, null, null);

Here is my complete getData method:

public Cursor getData() {

    Cursor cursorData = myDataBase.query(CSSTPipeSizingActivity.DB_TABLE, null, 
            CSSTPipeSizingActivity.spinnerPipeLengthText, null, null, null, null, null);
    if (cursorData != null)
        cursorData.moveToFirst();

    cursorData.moveToFirst();
    CSSTPipeSizingActivity.textViewSize15.setText(cursorData.getString(1));
    cursorData.moveToNext();        
    CSSTPipeSizingActivity.textViewSize19.setText(cursorData.getString(1));
    cursorData.moveToFirst();
    CSSTPipeSizingActivity.textViewSize25.setText(cursorData.getString(1));
    cursorData.moveToNext();        
    CSSTPipeSizingActivity.textViewSize31.setText(cursorData.getString(1));
    cursorData.moveToFirst();
    CSSTPipeSizingActivity.textViewSize37.setText(cursorData.getString(1));
    cursorData.moveToNext();        
    CSSTPipeSizingActivity.textViewSize46.setText(cursorData.getString(1));
    cursorData.moveToNext();        
    CSSTPipeSizingActivity.textViewSize62.setText(cursorData.getString(1));

    cursorData.close();
    return cursorData;
} // end method getData

As you can see from my code, I am trying to take the data and input it straight into text views in the main.xml file. I don’t know if this is possible but that will be for me to figure out later. Right now I need to get the data.

Here is my logcat:

03-12 19:23:33.587: D/AndroidRuntime(20191): Shutting down VM
03-12 19:23:33.587: W/dalvikvm(20191): threadid=1: thread exiting with uncaught exception (group=0x40015560)
03-12 19:23:33.617: E/AndroidRuntime(20191): FATAL EXCEPTION: main
03-12 19:23:33.617: E/AndroidRuntime(20191): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.skyesmechanical.CSSTPipeSizing/com.skyesmechanical.CSSTPipeSizing.CSSTPipeSizingActivity}: java.lang.NullPointerException
03-12 19:23:33.617: E/AndroidRuntime(20191):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
03-12 19:23:33.617: E/AndroidRuntime(20191):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
03-12 19:23:33.617: E/AndroidRuntime(20191):    at android.app.ActivityThread.access$1500(ActivityThread.java:117)
03-12 19:23:33.617: E/AndroidRuntime(20191):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
03-12 19:23:33.617: E/AndroidRuntime(20191):    at android.os.Handler.dispatchMessage(Handler.java:99)
03-12 19:23:33.617: E/AndroidRuntime(20191):    at android.os.Looper.loop(Looper.java:123)
03-12 19:23:33.617: E/AndroidRuntime(20191):    at android.app.ActivityThread.main(ActivityThread.java:3683)
03-12 19:23:33.617: E/AndroidRuntime(20191):    at java.lang.reflect.Method.invokeNative(Native Method)
03-12 19:23:33.617: E/AndroidRuntime(20191):    at java.lang.reflect.Method.invoke(Method.java:507)
03-12 19:23:33.617: E/AndroidRuntime(20191):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
03-12 19:23:33.617: E/AndroidRuntime(20191):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
03-12 19:23:33.617: E/AndroidRuntime(20191):    at dalvik.system.NativeStart.main(Native Method)
03-12 19:23:33.617: E/AndroidRuntime(20191): Caused by: java.lang.NullPointerException
03-12 19:23:33.617: E/AndroidRuntime(20191):    at com.skyesmechanical.CSSTPipeSizing.DataBaseHelper.getData(DataBaseHelper.java:173)
03-12 19:23:33.617: E/AndroidRuntime(20191):    at com.skyesmechanical.CSSTPipeSizing.CSSTPipeSizingActivity.onCreate(CSSTPipeSizingActivity.java:105)
03-12 19:23:33.617: E/AndroidRuntime(20191):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-12 19:23:33.617: E/AndroidRuntime(20191):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
03-12 19:23:33.617: E/AndroidRuntime(20191):    ... 11 more

Thanks for your help!

  • 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-31T06:47:41+00:00Added an answer on May 31, 2026 at 6:47 am

    Well, you’ re closing your cursor and then trying to return it… not gonna work too well that way. Either close the cursor and return nothing or return the cursor.

    You also keep iterating over the first couple entries when you do movetofirst, movetonext, then movetofirst again.

    I also believe your getString needs a little help.

    Here’s how I go about it:

    titleTxt.setText(eventedit.getString(eventedit
        .getColumnIndexOrThrow(AttendanceDB.EVENT_NAME)));
    

    titleTxt is a TextView reference I set earlier.
    eventEdit is the cursor I’m wanting to get the info from (and created earlier)
    AttendanceDB is my DB adapter class
    EVENT_NAME is the column name variable I set in my DB adapter class

    EDIT

    Ok, now that I re-read your question, I realize I was answering the wrong portion. The problem is your query is messed up. I think it should be more like this:

    Cursor cursorData = myDataBase.query(CSSTPipeSizingActivity.DB_TABLE, null,  
        COLUMN_ID + "=" + CSSTPipeSizingActivity.spinnerPipeLengthText, null, null, null, null, null);                           
    

    You need to tell the query what column to search for the info you want (CSSTPipeSizingActivity.spinnerPipeLengthText). So replace COLUMN_ID with your column name or the variable for it and you should be good to go.

    You really should review the info here, especially the various query method and their required parameters.

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

Sidebar

Related Questions

I'm trying to have my application read through a text file and look for
I have a kernel module that provides data to a userland process through read().
We currently have a read-through cache that uses optimistic concurrency control when filling the
I'm trying to localize my office add-in, I've read through many docs and tutorials
I have read through several reviews on Amazon and some books seem outdated. I
I have read through the solutions to similar problems, but they all seem to
I have read through the Rails docs for Routing , Restful Resources , and
Okay guys, I have read through all the other posts and question on jQuery
Ok, I'm programming in objective-C and using Xcode. I have read through the documentation
I have read the boost asio reference, gone through the tutorial and looked at

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.