daily pastebin goal
28%
SHARE
TWEET

Untitled

a guest Jun 19th, 2017 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2. * Here is the error I'm getting from logcat:
  3. * java.lang.RuntimeException: Unable to start activity ComponentInfo{com.droid.rx/com.droid.rx.dailyagenda}: * android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 2
  4. */
  5.  
  6.  
  7. // Here is the rawQuery to populate the cursor:
  8.  
  9.         if ("FRIDAY".equals(strDayOfWeek)) {
  10.             Cursor c = db.rawQuery(
  11.                     "SELECT * FROM tbl_prescription WHERE fri LIKE '1';", null);
  12.             showList(c);
  13.  
  14. // Code snipped of SimpleCursorAdapter.  It fails on execution:
  15.  
  16.     public void showList(Cursor c){
  17.         startManagingCursor(c);
  18.  
  19.         String[] from = new String[]{(c.getString(1)), (c.getString(2))};
  20.         int[] to = new int[] { android.R.id.text1, android.R.id.text2 };
  21.         ListAdapter adapter = new SimpleCursorAdapter(this,
  22.                 android.R.layout.two_line_list_item, c, from, to);
  23.        
  24.         setListAdapter(adapter);
  25.         c.close(); // Close cursor
  26.     }
RAW Paste Data
Top