I have the following code that accesses data on a database residing in /data/data/<app name>/databases (I copy my database from the assets dir into the databases dir at runtime).
c = myDB.rawQuery("SELECT * FROM "+dbTable+" WHERE name='"+line +"'", null); System.out.println ("Executing :: SELECT * FROM "+dbTable+" WHERE name='"+line+"'"); System.out.println ("Cols = "+c.getColumnCount()+", Col Idx for data = "+c.getColumnIndex("data")); return(c.getString(c.getColumnIndex("data"))); I can run the query manually and things look good. However at runtime the above code gives the following exception. Why is the cursor index out of bounds?? There are two columns and the "data" coln has the index of 1. Why is it saying that it is -1 even though I am passing it 1? Any idea? Database connection established Executing :: SELECT * FROM groceries WHERE name='yourlist3' Cols = 2, Col Idx for data = 1 android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 1 at android.database.AbstractCursor.checkPosition(AbstractCursor.java:580) at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java: 172) at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java: 41) at com.p2pSOAAndroidCP_16.DA.sqlite3DBHandler.query(sqlite3DBHandler.java: 84) at com.p2pSOAAndroidCP_16.DA.DiscoveryAgent $ServerConnection.run(DiscoveryAgent.java:1671) Database connection terminated -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en