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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:40:12+00:00 2026-05-26T19:40:12+00:00

I am making an android database app in which when i fetch values from

  • 0

I am making an android database app in which when i fetch values from database using cursor
It gives me the following exception.

java.lang.IllegalStateException: get field slot from row 0 col -1 failed

I am using the following code for fetching:

 public Cursor fetchChildren(String KEY_){

           Cursor c = db.rawQuery("SELECT children FROM " + DATABASE_TABLE_NAVIGATION
                   + " WHERE key_ = ?", new String[] {KEY_});
               return c;
           }



     try{   
     for(int k=0;k<n;k++){
       db.open();
     System.out.println("children are");
      Cursor cursor=db.fetchChildren(keys_a);
      if (cursor.moveToFirst()) // data?
            {
        System.out.println( cursor.getString(9)); 
     }
    }
 db.close();
    }
   catch(Exception e)
  {
  System.out.println(e);
      }
  • 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-26T19:40:12+00:00Added an answer on May 26, 2026 at 7:40 pm

    Use System.out.println( cursor.getString(0)) instead of System.out.println( cursor.getString(9));

    Or use System.out.println(cursor.getString(cursor.getColumnIndex("children"));

    Problem in your logic:

    You are fetching single column from your data base. So cursor having only one column (children). As you know that column index starts from 0 (0 for first column, 1 for 2nd column …), you have to pass 0 in getString(). Alternate way is, to search column index in cursor and pass that with getString(). as getColumnIndex(java.lang.String) calculate the index of column name in cursor, and use it within getString(int).

    Hope this will help.

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

Sidebar

Related Questions

I'm making an Android app, which gets its information from XML files. I'm filling
I'm new to android and making a sample app to load database from package/assets/test.mdb
I am making an android app in which I need to make different tables
I'm making Android app that has this database in it: public void onCreate(SQLiteDatabase db)
We are in the making of an Android app, a quiz game, which we
im making an android application which requires a user to register using a form
I'm making an Android app where the user can download files from a FTP-server.
I’m making an android app, which uses Google maps. One functionality is that the
I am new android, i'm making an app in which one can download files
I am making a search engine for my Android app that involves a database.

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.