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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T17:19:13+00:00 2026-05-21T17:19:13+00:00

I have setup a SQLite database in my android application. I used a tutorial

  • 0

I have setup a SQLite database in my android application. I used a tutorial from google and my database works (I can put data in it and read it out in an other form). Now, I want to get the column price and put it in a graph. I can draw the graph already with hard coded values. I’m trying:

Cursor item0 = _dbHelper.fetcAllBoughtItems();
startManagingCursor(item0);
String xaxis[]=new String[4];
        xaxis[0]= item0.getString(item0.getColumnIndexOrThrow(databaseManager.KEY_BOUGHT_ITEM));
        xaxis[1]="2007";
        xaxis[2]="2008";
        xaxis[3]="2009";

I get the follow error (I know it’s telling me what’s wrong, but I can’t get it fixed)

04-27 10:03:21.382: ERROR/AndroidRuntime(6920): java.lang.RuntimeException: Unable to start activity ComponentInfo{Adforce.files/Adforce.files.summarySpendBudget}: android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 5

Can someone help me please?
Regards

Edit:
fetchAllBoughtItems() code is:
public Cursor fetchAllBoughtItems(){ //function to fetch all bought items
return mDb.query(DATABASE_TABLE_ItemB, new String[]{KEY_ROWID_ItemB, KEY_BOUGHT_ITEM, KEY_PRICE_ItemB }, null, null, null, null, null);
}

  • 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-21T17:19:13+00:00Added an answer on May 21, 2026 at 5:19 pm

    fetcAllBoughtItems() returns Cursor without column named databaseManager.KEY_BOUGHT_ITEM

    fix fetcAllBoughtItems()

    EDIT:

    add item0.moveToFirst() before item0.getString(... and check if will return true

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

Sidebar

Related Questions

My setup: I have a sqlite database from which I populate a NSMutableArray of
I have a datalogging application (c#/.net) that logs data to a SQLite database. This
I have used below steps for setup the my emulator 1. C:\Program Files\android-sdk-windows\tools>adb shell
I have this setup where in my development copy I can commit changes on
I'm trying to set up a simple SQLite database in Android, handling the schema
I have a simple SQLite database I use to track invoices. I recently decided
I currently have a client / server setup where the client sends data to
I have setup web dav on windows server 2008. It seems to work fine
I have setup a property and implement INotifyPropertyChanged like so... public event PropertyChangedEventHandler PropertyChanged;
At the moment I have setup a custom ok cancel dialog with a drop

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.