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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:43:18+00:00 2026-05-27T16:43:18+00:00

I have a table with 6 columns in it, I’m trying to fetch all

  • 0

I have a table with 6 columns in it, I’m trying to fetch all rows from only 3 of the columns and store it in an array to use it. My query looks like this:

public Cursor fetchInfo(long rowId) throws SQLException
    {
        Cursor mCursor = mDb.query(true, DATABASE_TABLE, new String[] {"_id", "xCoord", "yCoord", "color"}, "_id" + "=" + rowId, null, null, null, null, null);

        if(mCursor != null)
        {
            mCursor.moveToFirst();
        }
        return mCursor;
    }

then I’m calling it like so:

private void getInfo()
    {
        Cursor mCursor = mDbHelper.fetchInfo(mRowId);
        x = new float[mCursor.getCount()];
        y = new float[mCursor.getCount()];
        color = new int[mCursor.getCount()];

        if(mCursor.moveToFirst())
        {
            for(int i = 0; i < mCursor.getCount(); i++)
            {
                x[i] = mCursor.getFloat(3);
                y[i] = mCursor.getFloat(4); //Line 76, this is where the error is occurs.
                color[i] = mCursor.getInt(5);
            }
        }
        mCursor.close();
    }

However, when I try to run this, I get an error saying:

12-19 15:40:36.903: E/CursorWindow(276): Bad request for field slot 0,4. numRows = 1, numColumns = 4
12-19 15:40:36.903: D/AndroidRuntime(276): Shutting down VM
12-19 15:40:36.912: W/dalvikvm(276): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
12-19 15:40:36.922: E/AndroidRuntime(276): FATAL EXCEPTION: main
12-19 15:40:36.922: E/AndroidRuntime(276): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.x17.projects.strikezone/com.x17.projects.strikezone.SavedEntries}: java.lang.IllegalStateException: get field slot from row 0 col 4 failed
12-19 15:40:36.922: E/AndroidRuntime(276):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
12-19 15:40:36.922: E/AndroidRuntime(276):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
12-19 15:40:36.922: E/AndroidRuntime(276):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
12-19 15:40:36.922: E/AndroidRuntime(276):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
12-19 15:40:36.922: E/AndroidRuntime(276):  at android.os.Handler.dispatchMessage(Handler.java:99)
12-19 15:40:36.922: E/AndroidRuntime(276):  at android.os.Looper.loop(Looper.java:123)
12-19 15:40:36.922: E/AndroidRuntime(276):  at android.app.ActivityThread.main(ActivityThread.java:4627)
12-19 15:40:36.922: E/AndroidRuntime(276):  at java.lang.reflect.Method.invokeNative(Native Method)
12-19 15:40:36.922: E/AndroidRuntime(276):  at java.lang.reflect.Method.invoke(Method.java:521)
12-19 15:40:36.922: E/AndroidRuntime(276):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
12-19 15:40:36.922: E/AndroidRuntime(276):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
12-19 15:40:36.922: E/AndroidRuntime(276):  at dalvik.system.NativeStart.main(Native Method)
12-19 15:40:36.922: E/AndroidRuntime(276): Caused by: java.lang.IllegalStateException: get field slot from row 0 col 4 failed
12-19 15:40:36.922: E/AndroidRuntime(276):  at android.database.CursorWindow.getDouble_native(Native Method)
12-19 15:40:36.922: E/AndroidRuntime(276):  at android.database.CursorWindow.getFloat(CursorWindow.java:451)
12-19 15:40:36.922: E/AndroidRuntime(276):  at android.database.AbstractWindowedCursor.getFloat(AbstractWindowedCursor.java:123)
12-19 15:40:36.922: E/AndroidRuntime(276):  at com.x17.projects.strikezone.SavedEntries.getInfo(SavedEntries.java:76)
12-19 15:40:36.922: E/AndroidRuntime(276):  at com.x17.projects.strikezone.SavedEntries.onCreate(SavedEntries.java:46)
12-19 15:40:36.922: E/AndroidRuntime(276):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
12-19 15:40:36.922: E/AndroidRuntime(276):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
12-19 15:40:36.922: E/AndroidRuntime(276):  ... 11 more

I am new to databases, so I’m not sure how to fix this. I’ve tried some different ways to fix this but with no success. What am I doing wrong here? Should I be doing this differently?

  • 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-27T16:43:19+00:00Added an answer on May 27, 2026 at 4:43 pm

    In your query inside the fetchInfo() method you are getting 4 columns from your DB Table.

    As the documentation states getFloat(int index) this method expects as index:

    index – the zero-based index of the target column.

    So you should use indexes as follows:

    0 – for _id

    1 – for xCoord

    2 – for yCoord

    3 – for color

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

Sidebar

Related Questions

i have a table with columns ID,SUBJECT,BRANCH i have select the rows which satisfies
I have table tblEvents with columns dEvent_Date, dEvent_Time, tEvent_Emp_Code_num I must group all dates
I Have Table with multiple columns and rows, Example, <table> <thead> <tr> <th>Head 1</th>
I have a table with columns user_id , time_stamp and activity which I use
Group, I have table columns ProductID, latitude,longitude,timestampGMT and looking for a query to count
I have a table with columns [a1,a2,a3,a4,a5....an] all the values are numeric. And I'd
The table columns have the data type BLOB and CLOB. What are the corresponding
I have table with 3 columns A B C. I want to select *
I have table with two columns (startdate & enddate) and I have two submission
I have a table with columns 'id', 'name', 'value', 'uniqueConst' in both databases. Now

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.