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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:42:14+00:00 2026-05-31T10:42:14+00:00

Ï developed a little SQLite database to add a list of goods, when I

  • 0

Ï developed a little SQLite database to add a list of goods, when I fletchallgoods through the database I have an error that says the index is not valid:

the code that generate the error:

...
Cursor goodsCursor = goodsfletcher.fetchAllGoods();
String goods[] = new String[goodsCursor.getCount()] ;
TableLayout tl = (TableLayout) findViewById(R.id.baskettable);
for(int i=0;i<=goods.length;i++){
    String Goodname = goodsCursor.getString(1).toString() ;
...

the clss Dbadapter that handle the conexion:

public Cursor fetchAllGoods() {

        return mDb.query(DATABASE_TABLE, new String[] {KEY_CODART, KEY_ARTI,
                KEY_PROV, KEY_PRECBOL, KEY_QUANT}, null, null, null, null, null);
}

The log cat of the error:

03-14 16:19:37.324: E/AndroidRuntime(5690): FATAL EXCEPTION: main
03-14 16:19:37.324: E/AndroidRuntime(5690): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.remotedata.firstapp/com.remotedata.firstapp.chartView}: android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 1
03-14 16:19:37.324: E/AndroidRuntime(5690):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1768)
03-14 16:19:37.324: E/AndroidRuntime(5690):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)
03-14 16:19:37.324: E/AndroidRuntime(5690):     at android.app.ActivityThread.access$1500(ActivityThread.java:123)
03-14 16:19:37.324: E/AndroidRuntime(5690):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
03-14 16:19:37.324: E/AndroidRuntime(5690):     at android.os.Handler.dispatchMessage(Handler.java:99)
03-14 16:19:37.324: E/AndroidRuntime(5690):     at android.os.Looper.loop(Looper.java:130)
03-14 16:19:37.324: E/AndroidRuntime(5690):     at android.app.ActivityThread.main(ActivityThread.java:3835)
03-14 16:19:37.324: E/AndroidRuntime(5690):     at java.lang.reflect.Method.invokeNative(Native Method)
03-14 16:19:37.324: E/AndroidRuntime(5690):     at java.lang.reflect.Method.invoke(Method.java:507)
03-14 16:19:37.324: E/AndroidRuntime(5690):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
03-14 16:19:37.324: E/AndroidRuntime(5690):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
03-14 16:19:37.324: E/AndroidRuntime(5690):     at dalvik.system.NativeStart.main(Native Method)
03-14 16:19:37.324: E/AndroidRuntime(5690): Caused by: android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 1
03-14 16:19:37.324: E/AndroidRuntime(5690):     at android.database.AbstractCursor.checkPosition(AbstractCursor.java:580)
03-14 16:19:37.324: E/AndroidRuntime(5690):     at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:214)
03-14 16:19:37.324: E/AndroidRuntime(5690):     at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:41)
03-14 16:19:37.324: E/AndroidRuntime(5690):     at com.remotedata.firstapp.chartView.onCreate(chartView.java:36)
03-14 16:19:37.324: E/AndroidRuntime(5690):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-14 16:19:37.324: E/AndroidRuntime(5690):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1722)
03-14 16:19:37.324: E/AndroidRuntime(5690):     ... 11 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-31T10:42:15+00:00Added an answer on May 31, 2026 at 10:42 am

    You need to move to the first record in your Cursor before retrieving values.

    Ex.

    Cursor goodsCursor = goodsfletcher.fetchAllGoods();
    String goods[] = new String[goodsCursor.getCount()] ;
    TableLayout tl = (TableLayout) findViewById(R.id.baskettable);
    if (c.moveToFirst()){
        do {
            String Goodname = goodsCursor.getString(1).toString() ;
        }while (c.moveToNext());
    
    
    }
    
    c.close();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a little problem. I have developed a midlet application that call some
I have developed a small app that stores locally in iOS through archiving an
I've developed a little screenshot application but I've heard that I should profile my
I'm a little confused. We have developed an net 4.0 application. We use nhibernate
I have developed several GWT Web Applications. Latest one is a little modification of
I have developed a little software in ACCESS/VBA. It dealt with Lotus Notes so
I have developed a website, using Twitter API. Now a little but important problem
I have developed an android app that mainly targets smartphones. However in tablet emulator
I have developed a little game using XNA 4.0 and C# (new Project->Windows Game
I have a very unreasonable requirement from my overlord. I developed a little application

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.