Note that there are some explanatory texts on larger screens.

plurals
  1. POFC when looking for record in SQLite
    primarykey
    data
    text
    <p>I have several methods for getting a record in my app<Br> But for some reason this one keeps giving me FC ! I'm using the following method to get the Cursor :</p> <pre><code>Cursor c=helper.getRecordById(num); </code></pre> <p>Which is implemented as follows :</p> <pre><code>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)); } </code></pre> <p>I have tried also without converting the Int to String but i just left it this way.. get the same error for both ways.</p> <p>Whenever i get to the following line :</p> <pre><code>String name=c.getString(c.getColumnIndexOrThrow("OrderName")); </code></pre> <p>I get the FC. The GetColumnIndex works just fine... i've tested it exclusively. But the getString throws the error. :</p> <pre><code>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 </code></pre> <p><strong>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 !</strong></p> <p><strong>Thanks !!!</strong></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload