Users Pricing

forum

Home Forums CursorIndexOutOfBoundsException for table and records existing – MindStick

CursorIndexOutOfBoundsException for table and records existing

Mark Devid 2536 30 May 2013
Hi Expert!

I am querying the database with the following query:

final Cursor subject_cursor = db.rawQuery("SELECT * FROM " + DB.Table.SUBJECT + " WHERE uniqueSUB = '" + cs_cursor.getString(1) + "'", null);
when i log the cursor count it gives me 1 as the count, but when i try to access the data using subject_cursor.getString(0) it gives me an error saying:

    05-30 03:37:10.921: W/System.err(5408): android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 1 I have checked the database for the records manually and all the required data is present. (Also if i just do a following query:

    "SELECT * FROM " + DB.Table.SUBJECT"
for the same table and give the get the count for the cursor it gives me the existing number of records which is correct).

Please Do Help...

Thanks in advance. 

1 Answers

Markdown for AI

A clean, structured version of this page for AI assistants and LLMs.

Open .md