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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:40:21+00:00 2026-06-04T21:40:21+00:00

I have several methods for getting a record in my app But for some

  • 0

I have several methods for getting a record in my app

But for some reason this one keeps giving me FC !
I’m using the following method to get the Cursor :

Cursor c=helper.getRecordById(num);

Which is implemented as follows :

public Cursor getRecordById(int rowId) {
    String rowIDs=""+rowId;
    String SelectById = "SELECT id, OrderName, OrderLink, DateYear, DateMonth, DateDay, OrderPrice FROM Orders WHERE id=?";
    String[] args={rowIDs};
    return(getReadableDatabase().rawQuery(SelectById, args));
}

I have tried also without converting the Int to String but i just left it this way.. get the same error for both ways.

Whenever i get to the following line :

String name=c.getString(c.getColumnIndexOrThrow("OrderName"));

I get the FC.
The GetColumnIndex works just fine… i’ve tested it exclusively.
But the getString throws the error. :

06-02 21:07:13.656: W/KeyCharacterMap(4329): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
06-02 21:07:16.006: D/AndroidRuntime(4329): Shutting down VM
06-02 21:07:16.006: W/dalvikvm(4329): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
06-02 21:07:16.026: E/AndroidRuntime(4329): FATAL EXCEPTION: main
06-02 21:07:16.026: E/AndroidRuntime(4329): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.Sagi.MyOrders/com.Sagi.MyOrders.DisplayRecord}: android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 0
06-02 21:07:16.026: E/AndroidRuntime(4329):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
06-02 21:07:16.026: E/AndroidRuntime(4329):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
06-02 21:07:16.026: E/AndroidRuntime(4329):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
06-02 21:07:16.026: E/AndroidRuntime(4329):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
06-02 21:07:16.026: E/AndroidRuntime(4329):     at android.os.Handler.dispatchMessage(Handler.java:99)
06-02 21:07:16.026: E/AndroidRuntime(4329):     at android.os.Looper.loop(Looper.java:123)
06-02 21:07:16.026: E/AndroidRuntime(4329):     at android.app.ActivityThread.main(ActivityThread.java:4627)
06-02 21:07:16.026: E/AndroidRuntime(4329):     at java.lang.reflect.Method.invokeNative(Native Method)
06-02 21:07:16.026: E/AndroidRuntime(4329):     at java.lang.reflect.Method.invoke(Method.java:521)
06-02 21:07:16.026: E/AndroidRuntime(4329):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
06-02 21:07:16.026: E/AndroidRuntime(4329):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
06-02 21:07:16.026: E/AndroidRuntime(4329):     at dalvik.system.NativeStart.main(Native Method)
06-02 21:07:16.026: E/AndroidRuntime(4329): Caused by: android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 0
06-02 21:07:16.026: E/AndroidRuntime(4329):     at android.database.AbstractCursor.checkPosition(AbstractCursor.java:580)
06-02 21:07:16.026: E/AndroidRuntime(4329):     at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:214)
06-02 21:07:16.026: E/AndroidRuntime(4329):     at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:41)
06-02 21:07:16.026: E/AndroidRuntime(4329):     at com.Sagi.MyOrders.DisplayRecord.onCreate(DisplayRecord.java:48)
06-02 21:07:16.026: E/AndroidRuntime(4329):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-02 21:07:16.026: E/AndroidRuntime(4329):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
06-02 21:07:16.026: E/AndroidRuntime(4329):     ... 11 more
06-02 21:12:16.126: I/Process(4329): Sending signal. PID: 4329 SIG: 9

The funny thing is i copied the same exact Lookup method i used in another place which works just fine !, i even tried giving it a constant to look for which i know to exists just to check. but nothing. error over and over again !

Thanks !!!

  • 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-06-04T21:40:23+00:00Added an answer on June 4, 2026 at 9:40 pm

    A Cursor initially points to a record one before the start, to allow this kind of code:

    final Cursor cursor = /* get cursor */;
    while(cursor.moveToNext()) {
        /* do something with cursor */
    }
    

    If you are only expecting one record, and you are sure there will be one record, then before accesing your Cursor do:

    cursor.moveToNext();
    

    or:

    cursor.moveToFirst();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

iI have some trouble getting sth like this to work in java: public class
Several questions has been asked related to this error, but each one of them
I already tried several methods getting my xml-script parsed in java, but i can't
I have several methods in my DAL, with quite a few parameters: public Collection<Proforma>
I have several methods that populate a SQLCommand objects parameter collection from an object
I have several methods that have a return type IEnumerable<T> . These methods are
I have several classes each containing several methods annotated with @Test . The classes
ASP.Net MVC Controllers have several methods of forwarding control to another controller or action.
I have a model called City. I have several methods that look for a
I have an interface, IMessage and a class which have several methods for creating

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.