title: Simple Cursor Adapter problem
body: <p>Here is my code for a simple cursor adapter.</p>
  
  <pre><code>public class CursorList extends ListActivity {
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
  
      DatabaseAdapter da = new DatabaseAdapter(this, "mydb.sqlite");
  
      da.open();
      Cursor cur = da.fetchAllRecords("Doctors", new String[]{"FirstName"});
      startManagingCursor(cur);
  
      cur.moveToFirst();
      do {
          Log.v("Info", cur.getString(cur.getColumnIndex("FirstName")));
      } while(cur.moveToNext());
  
      cur.moveToFirst();
  
      String[] from = new String[]{"FirstName"};
      int[] to = new int[]{R.id.row};
  
      SimpleCursorAdapter sca = new SimpleCursorAdapter(this, R.layout.row_item, cur, from, to);
  
      setListAdapter(sca);
      }
  }
  </code></pre>
  
  <p>The data records are displayed correctly in the log, but the code stops working when it reaches the </p>
  
  <pre><code>SimpleCursorAdapter sca = new SimpleCursorAdapter(this, R.layout.row_item, cur, from, to);
  </code></pre>
  
  <p>line.</p>
  
  <p>The error I get is : </p>
  
  <pre><code>ERROR/AndroidRuntime(26746): Uncaught handler: thread main exiting due to uncaught exception
  ERROR/AndroidRuntime(26746): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.arnab.cursorlist/com.arnab.cursorlist.CursorList}:
  java.lang.IllegalArgumentException: column '_id' does not exist
  </code></pre>
  
  <p>Where am I going wrong? </p>
  
  <p>Why does it give an error that column '_id' doesn't exist? Is it a necessary column which we have to have in our tables?</p>
  
  <p>EDIT:</p>
  
  <p>When I put the cursor related code in a try catch block, something like this:</p>
  
  <pre><code>try {
          SimpleCursorAdapter sca = new SimpleCursorAdapter(this, R.layout.row_item, cur, from, to);
  
          setListAdapter(sca);
      }
      catch(Exception E) {
          Log.v("Error", E.getMessage());
      }
  </code></pre>
  
  <p>I get the message :</p>
  
  <pre><code>VERBOSE/Error(1026): column '_id' does not exist
  </code></pre>
  
  <p>@Rasel : Here is the <code>fetchAllRecords</code> method</p>
  
  <pre><code>public Cursor fetchAllRecords(String table, String columns[]) {
      return mDb.query(table, columns, null, null, null, null, null);     
  }
  </code></pre>