title: Retrieving a BLOB type into Byte
body: <p>SQLiteDatabase DB = this.getReadableDatabase();
          ImageModel ImageModel = new ImageModel();</p>
  
  <blockquote>
    <p>So here is my snippet</p>
  </blockquote>
  
  <pre><code>    Cursor Cursor = DB.rawQuery("SELECT ImageFile FROM Image WHERE ID = '1'", null);
  
      if(Cursor.getCount() &lt; 1) {
          System.out.println("NO DATA");
      }else {
          System.out.println("HAVE DATA");
          byte[] byteArray = Cursor.getBlob(1);
          ImageModel.setImage(BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length));
      }
  </code></pre>
  
  <blockquote>
    <p>I got an error from this code <code>
            byte[] byteArray = Cursor.getBlob(1);</code></p>
  </blockquote>
  
  <pre><code>Caused by: android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 1
  </code></pre>