title: android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0
body: <p>I am using custom adapter extending cursor adapter for displaying data in listview, to display particular phone number i have passed the id to a method in database class but it is showing </p>
  
  <pre><code>errorandroid.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0 
  </code></pre>
  
  <p>while placing debugger in the the method it is not going after the line</p>
  
  <pre><code>num = cursor.getString(cursor.getColumnIndex("ContactNumber"));
  </code></pre>
  
  <p>Can any one help me to solve it.
  This is the code:</p>
  
  <pre><code>public String getNumberFromId(int id) 
  {
      String num;
      db= this.getReadableDatabase();
      Cursor cursor = db.query(scheduletable, new String[] { "ContactNumber" },"_id="+id, null, null, null, null);
      cursor.moveToFirst();
      num = cursor.getString(cursor.getColumnIndex("ContactNumber")); 
      cursor.close();
      db.close();
      return num;
  }
  </code></pre>