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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:03:01+00:00 2026-05-25T23:03:01+00:00

When i use the cursor.moveToNext(); in my code then the application Force finishing activity

  • 0

When i use the cursor.moveToNext(); in my code then the application Force finishing activity when i am scrolling down the bottom but when i am remove cursor.moveToNext(); it works normally ?

class NoteHolder {
private Button b1 = null;
private Button b2 = null;
private Button b3 = null;


NoteHolder(View row) {
    b1 = (Button) row.findViewById(R.id.one);
    b2 = (Button) row.findViewById(R.id.two);
    b3 = (Button) row.findViewById(R.id.three);

}

void populateFrom(Cursor c, NoteHelper helper) {
    b1.setText(helper.getNote(c));
        c.moveToNext();
    b2.setText(helper.getNote(c));
    c.moveToNext();
    b3.setText(helper.getNote(c));
}

}

Errors are

    ERROR/AndroidRuntime(622): FATAL EXCEPTION: main
ERROR/AndroidRuntime(622): android.database.CursorIndexOutOfBoundsException: Index 16 requested, with a size of 16
ERROR/AndroidRuntime(622):     at android.database.AbstractCursor.checkPosition(AbstractCursor.java:580)
 ERROR/AndroidRuntime(622):     at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:214)
ERROR/AndroidRuntime(622):     at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:41)
ERROR/AndroidRuntime(622):     at com.example.buttontest.ButtonTest$NoteHelper.getNote(ButtonTest.java:141)
ERROR/AndroidRuntime(622):     at com.example.buttontest.ButtonTest$NoteHolder.populateFrom(ButtonTest.java:105)
ERROR/AndroidRuntime(622):     at com.example.buttontest.ButtonTest$NoteAdapter.bindView(ButtonTest.java:71)
 ERROR/AndroidRuntime(622):     at android.widget.CursorAdapter.getView(CursorAdapter.java:186)
ERROR/AndroidRuntime(622):     at android.widget.AbsListView.obtainView(AbsListView.java:1294)
ERROR/AndroidRuntime(622):     at android.widget.ListView.makeAndAddView(ListView.java:1727)
ERROR/AndroidRuntime(622):     at android.widget.ListView.fillDown(ListView.java:652)
ERROR/AndroidRuntime(622):     at android.widget.ListView.fillGap(ListView.java:623)
ERROR/AndroidRuntime(622):     at android.widget.AbsListView.trackMotionScroll(AbsListView.java:2944)
ERROR/AndroidRuntime(622):     at android.widget.AbsListView$FlingRunnable.run(AbsListView.java:2485)
ERROR/AndroidRuntime(622):     at android.os.Handler.handleCallback(Handler.java:587)
ERROR/AndroidRuntime(622):     at android.os.Handler.dispatchMessage(Handler.java:92)
ERROR/AndroidRuntime(622):     at android.os.Looper.loop(Looper.java:123)
 ERROR/AndroidRuntime(622):     at android.app.ActivityThread.main(ActivityThread.java:4627)
 ERROR/AndroidRuntime(622):     at java.lang.reflect.Method.invokeNative(Native Method)
ERROR/AndroidRuntime(622):     at java.lang.reflect.Method.invoke(Method.java:521)
 ERROR/AndroidRuntime(622):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
ERROR/AndroidRuntime(622):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
ERROR/AndroidRuntime(622):     at dalvik.system.NativeStart.main(Native Method)
  • 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-25T23:03:02+00:00Added an answer on May 25, 2026 at 11:03 pm

    when you get a Cursor returned from the database you should do an moveToFirst(); before trying to get data from it. try this

    void populateFrom(Cursor c, NoteHelper helper) {
        if (!c.moveToFirst()) return; //if no data dont do anything
        b1.setText(helper.getNote(c));
            c.moveToNext();
        b2.setText(helper.getNote(c));
        c.moveToNext();
        b3.setText(helper.getNote(c));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use a cursor loop in MYSQL, but it's not working. I've
I want to use the google maps hand cursor in Python but I don't
I always use the code below to get all the informations But I have
In my application I use cursor to get information from SQLite data base like
Is it possible to Use cursor in triggers in MySQL? Is it recommended? as
For example, when I use cursor.execute() as documented : >>> from django.db import connection
I am trying to use a cursor with a managed query to filter media
I'm not sure when it is appropriate to use a cursor. I need to
I want to use a hardware cursor for a computer game I am making,
I am making use of a custom cursor on itemRenderers in a List component.

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.