title: Failed to read row 0, column 0 from a CursorWindow which has 0 rows, 1 columns
body: <p>I have an android app that is trying to load a blob from an SQLite database as a byte array:</p>
  
  <pre><code>public byte[] getBytesForId(long id){
      byte[] result = null;
      String sql =  "SELECT _blob FROM test_table WHERE _id=?";
      String[] selection = new String[] { String.valueOf(id) };
  
      Cursor mCursor = super.DB().rawQuery(sql, selection);
  
      if ( mCursor != null &amp;&amp; mCursor.moveToFirst() ) {               
          if (mCursor.getCount() &gt; 0)
              result = mCursor.getBlob(0);
  
          if (mCursor != null &amp;&amp; !mCursor.isClosed())
              mCursor.close();
      }
  
      return result;
  }
  </code></pre>
  
  <p>but I get the following exception:</p>
  
  <pre><code>Failed to read row 0, column 0 from a CursorWindow which has 0 rows, 1 columns.
  java.lang.IllegalStateException: Couldn't read row 0, col 0 from CursorWindow.  Make sure the Cursor is initialized correctly before accessing data from it.
  at android.database.CursorWindow.nativeGetBlob(Native Method)
  at android.database.CursorWindow.getBlob(CursorWindow.java:404)
  at android.database.AbstractWindowedCursor.getBlob(AbstractWindowedCursor.java:45)
  at com.test.testapp.model.DbClass.getBytesForId(DbClass.java:218)
  at com.test.testapp.TestService.StepThroughBlocks(TestService.java:434)
  at com.test.testapp.TestService.checkBlocks(TestService.java:378)
  at com.test.testapp.TestService.access$4(TestService.java:357)
  at com.test.testapp.TestService$2.run(TestService.java:315)
  at java.lang.Thread.run(Thread.java:841)
  </code></pre>
  
  <p>surely if I am checking that the cursor has some data first...</p>
  
  <pre><code>if ( mCursor != null &amp;&amp; mCursor.moveToFirst() ) 
          if (mCursor.getCount() &gt; 0)
              result = mCursor.getBlob(0);
  </code></pre>
  
  <p>...I shouldn't be getting this exception? I added the mCursor.getCount line hoping that might help but I'm still getting the exception. How is this possible? </p>