jeudi 23 avril 2015

How to solve android.database.CursorIndexOutOfBoundsException in SQLite [multiple questions]?

enter image description here

I have the above shown table in my database and the following query in my populate list

Cursor cursor = db.rawQuery("select id, title, date, week, note, cost, time, catid from entry order by date", null);

  1. The problem that arises when accessing the catid is it throws this runtime exception

    android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 4
    
    

on this line

Int id = cursor.getInt(7);

2. Everytime i save the user inputs the app crahses but when it reopens it shows the last taken inputs. It doesn't populate them on runtime The error that it shows is (for codes please refer to this question)

java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=null}

3. How do i add particular fields for example in the above table i have a column named cost so i want to display the sum of costs of a day how do i do that?

Aucun commentaire:

Enregistrer un commentaire