Android Question android.database.CursorIndexOutOfBoundsException error

Discussion in 'Android Questions' started by apty, Dec 28, 2018.

  1. apty

    apty Active Member Licensed User

    What would cause the error below?:

    Code:
    android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 149
    I have an app which was just working fine inserting and reading data from sqlite database but from yesterday it stopped working generating the above error.
     
  2. DonManfred

    DonManfred Expert Licensed User

    The bad weather in Florida?

    Help us helping you:
    Start with posting all relevant code so we could give a more congrete answer. Best is to upload a small project which shows the issue.
     
    jimmyF and mangojack like this.
  3. apty

    apty Active Member Licensed User

    The code below is the one generating the error. Everything was working fine until yesterday

    Code:
    Dim SenderFilter As Object = Starter.sql1.ExecQueryAsync("SQL""SELECT * FROM newnames order by firstname asc"Null)
        
    Wait For (SenderFilter) SQL_QueryComplete (Success As Boolean, rs As ResultSet)
        
        
    Log(Success)
        
    If Success Then
            
    Do While rs.NextRow
    lsUsers.AddTwoLinesAndBitmap2(rs.GetString(
    "firstname"),rs.GetString("lastname"),BytesToImage(rs.GetBlob("usericon")),rs.GetString("username"))
    Loop
            rs.Close
        
    Else
            
    Log(LastException)
            
        
    End If
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Can you post the full error message from the logs?
     
  5. apty

    apty Active Member Licensed User

    The full error log is as below:
    Code:
    true
    main$ResumableSub_loaduserlistresume (java line: 
    1981)
    android.database.CursorIndexOutOfBoundsException: Index -
    1 requested, with a size of 149
        at android.database.AbstractCursor.checkPosition(AbstractCursor.java:
    460)
        at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:
    136)
        at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:
    50)
        at anywheresoftware.b4a.sql.SQL$CursorWrapper.GetString(
    SQL.java:377)
        at users.icons.listm.main$ResumableSub_loaduserlist.resume(main.java:
    1981)
        at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:
    245)
        at anywheresoftware.b4a.BA.raiseEvent2(BA.java:
    185)
        at anywheresoftware.b4a.BA$
    2.run(BA.java:365)
        at android.os.Handler.handleCallback(Handler.java:
    789)
        at android.os.Handler.dispatchMessage(Handler.java:
    98)
        at android.os.Looper.loop(Looper.java:
    164)
        at android.app.ActivityThread.main(ActivityThread.java:
    6938)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:
    327)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:
    1374)
     
  6. DonManfred

    DonManfred Expert Licensed User

    Sounds like one of firstname, lastname or username is not available in the resultset
     
  7. apty

    apty Active Member Licensed User

    the app started working again without any modification to the code. I don't know what was happening.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice