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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:10:42+00:00 2026-05-26T08:10:42+00:00

I have a problem with my cursor which I know the error of, but

  • 0

I have a problem with my cursor which I know the error of, but hav eNO clue how to solve this.
Let me explain the idea im trying to achieve first before diving into code-mode.

I have two tables in SQL lite.

tbl_checkpoints
_id | parent_id | title | is_checked | quantity

tbl_checkpoint_answers
_id | parent_id | answer | note | is_checked

Cursor wise since both have an equal amount of columns, the array would ofcourse be:
0 = _id
1 = parent_id
2 = title/answer
3 = is_checked/note
4 = quantity/is_checked
(before the / is tbl_checkpoints, after is tbl_checkpoint_answers)

A checkpoint can have a quantity. Let’s say for example the quantity is 5.
Then a checkpoint requires to be checked 5 times. On a house for example, the checkpoint would be;
“Is brick in perfect condition”
brick 1: yes
brick 2: yes
brick 3: no
brick 4: no
brick 5: yes

These answers belong in the table_checkpoint_answers table.
One to many relationship.
One checkpoint can have multiple answers.

Code wise, I am using an activity that displays a form, to fill in a checkpoint.
In the form, which resides in a tab layout.

I have a setup like this in onCreate()

_checkPointCursor = _dbHelper.fetchAllCheckPoints(_parentId);

//I know startManagingCursor() is deprecated. I don't know how to use the new version yet.
startManagingCursor(_checkpointCursor); 

_cursor.moveToPosition(_position);
_answerCursor = _dbHelper.fetchFirstCheckPointAnswer(_checkPointCursor.getInt(0)); 
//getInt(0) returns 1 which is what I expect. (debugged)

What happens here is I have a cursor that has all checkpoints where parentid is equal to a given number. 1 in this case(tested. Forced it to be 1, which im sure of the query will give results.

The query I use for fetchAllCheckPoints(_parentId); is:

SELECT * FROM tbl_checkpoints WHERE parent_id = parentId // parentId = 1

This gives me 5 results. This is true in the program aswell and it works fine uptil now.
_checkpointCursor mCount is 5 according to the debugger.

The next query; fetchFirstCheckPointAnswer(); is :

    SELECT * FROM tbl_checkpointAnswers WHERE parent_id = parentId ORDER BY _id ASC LIMIT 0,1
   //primary key of the selected _checkPointCursor() which is 1. so parentId = 1. 
   //Things going well so far..

After this query has fired (I have checked using 2 kinds of software, I get 1 result. Which is exactly what I want.

The cursor now sais mCount = -1.
Why? why is mCount on _answerCursor -1?
I am sure I get a result from the query.

the program later crashes when I use:

textView.setText(_answerCursor.getString(2));

The stacktrace:

10-19 14:10:04.651: ERROR/AndroidRuntime(12997): FATAL EXCEPTION: main10-19 14:10:04.651: ERROR/AndroidRuntime(12997): java.lang.RuntimeException: Unable to resume activity {com.wvds.activities/com.wvds.activities.TabbedCheckPointActivity}: java.lang.RuntimeException: Unable to resume activity {com.wvds.activities/com.wvds.activities.CheckPointFormActivity}: android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 110-19 14:10:04.651: ERROR/AndroidRuntime(12997):     at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3128)10-19 14:10:04.651: ERROR/AndroidRuntime(12997):     at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3143)10-19 14:10:04.651: ERROR/AndroidRuntime(12997):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2684)10-19 14:10:04.651: ERROR/AndroidRuntime(12997):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)10-19 14:10:04.651: ERROR/AndroidRuntime(12997):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)10-19 14:10:04.651: ERROR/AndroidRuntime(12997):     at android.os.Handler.dispatchMessage(Handler.java:99)10-19 14:10:04.651: ERROR/AndroidRuntime(12997):     at android.os.Looper.loop(Looper.java:123)10-19 14:10:04.651: ERROR/AndroidRuntime(12997):     at android.app.ActivityThread.main(ActivityThread.java:4627)10-19 14:10:04.651: ERROR/AndroidRuntime(12997):     at java.lang.reflect.Method.invokeNative(Native Method)10-19 14:10:04.651: ERROR/AndroidRuntime(12997):     at java.lang.reflect.Method.invoke(Method.java:521)10-19 14:10:04.651: ERROR/AndroidRuntime(12997):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)10-19 14:10:04.651: ERROR/AndroidRuntime(12997):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)10-19 14:10:04.651: ERROR/AndroidRuntime(12997):     at dalvik.system.NativeStart.main(Native Method)10-19 14:10:04.651: ERROR/AndroidRuntime(12997): Caused by: java.lang.RuntimeException: Unable to resume activity {com.wvds.activities/com.wvds.activities.CheckPointFormActivity}: android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 110-19 14:10:04.651: ERROR/AndroidRuntime(12997):     at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3128)10-19 14:10:04.651: ERROR/AndroidRuntime(12997):     at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:170)10-19 14:10:04.651: ERROR/AndroidRuntime(12997):     at android.app.LocalActivityManager.dispatchResume(LocalActivityManager.java:518)10-19 14:10:04.651: ERROR/AndroidRuntime(12997):     at android.app.ActivityGroup.onResume(ActivityGroup.java:58)10-19 14:10:04.651: ERROR/AndroidRuntime(12997):     at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1149)10-19 14:10:04.651: ERROR/AndroidRuntime(12997):     at android.app.Activity.performResume(Activity.java:3823)10-19 14:10:04.651: ERROR/AndroidRuntime(12997):     at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3118)10-19 14:10:04.651: ERROR/AndroidRuntime(12997):     ... 12 more10-19 14:10:04.651: ERROR/AndroidRuntime(12997): Caused by: android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 110-19 14:10:04.651: ERROR/AndroidRuntime(12997):     at android.database.AbstractCursor.checkPosition(AbstractCursor.java:580)10-19 14:10:04.651: ERROR/AndroidRuntime(12997):     at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:214)10-19 14:10:04.651: ERROR/AndroidRuntime(12997):     at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:41)10-19 14:10:04.651: ERROR/AndroidRuntime(12997):     at com.wvds.activities.CheckPointFormActivity.loadView(CheckPointFormActivity.java:289)10-19 14:10:04.651: ERROR/AndroidRuntime(12997):     at com.wvds.activities.CheckPointFormActivity.onResume(CheckPointFormActivity.java:126)10-19 14:10:04.651: ERROR/AndroidRuntime(12997):     at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1149)10-19 14:10:04.651: ERROR/AndroidRuntime(12997):     at android.app.Activity.performResume(Activity.java:3823)10-19 14:10:04.651: ERROR/AndroidRuntime(12997):     at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3118)10-19 14:10:04.651: ERROR/AndroidRuntime(12997):     ... 18 more

I hope someone will be able to help me resolve this issue. I look forward to reading your answers/help.

Thanks in advance.

Btw, In case I have typos, in the actual code there are no typos. Not that prevent it from running.
Due to the situation im in. I cant use internet on my programming pc. So I use an internet pc to write this.

  • 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-26T08:10:42+00:00Added an answer on May 26, 2026 at 8:10 am

    Before fatch data you add cursor.movetofirst();

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

Sidebar

Related Questions

I have problem compilin this code..can anyone tell whats wrong with the syntax CREATE
I have a query which uses a cursor to cycle through the results of
slight problem. I have a 20 x 20px delete icon which I want to
Q: I have the following problem , and i don't know how to fix
Problem 1. I have this class: public class ContactGroups { // Form an array
I have no problem in writing data in excel sheet which is stored in
I'm creating an application and I have problems with Cursor . I have an
I have problem in some JavaScript that I am writing where the Switch statement
I have problem with return statment >.< I want to store all magazine names
I have problem with starting processes in impersonated context in ASP.NET 2.0. I am

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.