title: CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0. Error - Android
body: <p>I'm trying to get the position id of a child in an expandableListView and start another class based on what child is clicked on and I'm doing that like this:</p>
  
  <pre><code>    @Override
      public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) 
      {
          // TODO Auto-generated method stub
          super.onChildClick(parent, v, groupPosition, childPosition, id);
          Intent i = new Intent(this, SavedEntries.class);
          i.putExtra("_id", id);
          startActivityForResult(i, ACTIVITY_EDIT);
          return super.onChildClick(parent, v, groupPosition, childPosition, id);
      }
  </code></pre>
  
  <p>But I keep getting this error:</p>
  
  <pre><code>01-05 13:14:28.232: E/AndroidRuntime(316): FATAL EXCEPTION: main
  01-05 13:14:28.232: E/AndroidRuntime(316): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.x17.projects.strikezone/com.x17.projects.strikezone.SavedEntries}: android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0
  01-05 13:14:28.232: E/AndroidRuntime(316):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
  01-05 13:14:28.232: E/AndroidRuntime(316):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
  01-05 13:14:28.232: E/AndroidRuntime(316):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
  01-05 13:14:28.232: E/AndroidRuntime(316):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
  01-05 13:14:28.232: E/AndroidRuntime(316):  at android.os.Handler.dispatchMessage(Handler.java:99)
  01-05 13:14:28.232: E/AndroidRuntime(316):  at android.os.Looper.loop(Looper.java:123)
  01-05 13:14:28.232: E/AndroidRuntime(316):  at android.app.ActivityThread.main(ActivityThread.java:4627)
  01-05 13:14:28.232: E/AndroidRuntime(316):  at java.lang.reflect.Method.invokeNative(Native Method)
  01-05 13:14:28.232: E/AndroidRuntime(316):  at java.lang.reflect.Method.invoke(Method.java:521)
  01-05 13:14:28.232: E/AndroidRuntime(316):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
  01-05 13:14:28.232: E/AndroidRuntime(316):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
  01-05 13:14:28.232: E/AndroidRuntime(316):  at dalvik.system.NativeStart.main(Native Method)
  01-05 13:14:28.232: E/AndroidRuntime(316): Caused by: android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0
  01-05 13:14:28.232: E/AndroidRuntime(316):  at android.database.AbstractCursor.checkPosition(AbstractCursor.java:580)
  01-05 13:14:28.232: E/AndroidRuntime(316):  at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:214)
  01-05 13:14:28.232: E/AndroidRuntime(316):  at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:41)
  01-05 13:14:28.232: E/AndroidRuntime(316):  at com.x17.projects.strikezone.SavedEntries.getDateRow(SavedEntries.java:56)
  01-05 13:14:28.232: E/AndroidRuntime(316):  at com.x17.projects.strikezone.SavedEntries.onCreate(SavedEntries.java:48)
  01-05 13:14:28.232: E/AndroidRuntime(316):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
  01-05 13:14:28.232: E/AndroidRuntime(316):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
  01-05 13:14:28.232: E/AndroidRuntime(316):  ... 11 more
  </code></pre>
  
  <p>This is where I'm sending the id to:</p>
  
  <pre><code>Bundle extras = getIntent().getExtras();
  mRowId = extras != null ? extras.getLong("_id") : null;
  
      private void getDateRow()
      {
          Cursor mCursor = mDbHelper.fetchRow(mRowId);
          date = mCursor.getString(0); //Line 56, this is where the error occurs.
          mCursor.close();
      }
  </code></pre>
  
  <p>And here's the query for above:</p>
  
  <pre><code>public Cursor fetchRow(long rowId)
      {
          Cursor cursor = mDb.rawQuery("SELECT date FROM entry WHERE _id=" + rowId, null);
          if(cursor != null)
          {
              cursor.moveToFirst();
          }
          return cursor;
      }
  </code></pre>
  
  <p>Why am I getting this error? What am I doing wrong here?</p>
  
  <p>Thanks in advance.</p>