title: Db to ListView error
body: <p>I am trying to create a list view from the database. this is the code</p>
  
  <p>List Activity</p>
  
  <pre><code> protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.inbox);
  
    DBAdapter db = new DBAdapter(InboxActivity.this);
    db.open();
    long userID = Long.parseLong(MessagingApplication.getUserID());
  
    Cursor inbox = db.readInbox(userID);
    startManagingCursor(inbox);
  
    String[] mails = new String[] { DBAdapter.KEY_NAME };
  
    int[] to = new int[] { R.id.name };
  
    SimpleCursorAdapter inboxmail = new SimpleCursorAdapter(this,
      R.layout.inbox_list, inbox, mails, to);
  
    setListAdapter(inboxmail);
  
    db.close();
   }
  </code></pre>
  
  <p>This is the code that fetches data from the DB</p>
  
  <pre><code> public Cursor readInbox(long toId) throws SQLException {
    return db.query(TABLE_MAILS, new String[] { ID, KEY_FROM, KEY_TO,
      KEY_SUB, KEY_BODY, KEY_DATETIME, KEY_READ }, KEY_TO + "="
      + toId, null, null, null, null, null);
   }
  </code></pre>
  
  <p>My DB</p>
  
  <pre><code>private static final String CREATE_MAILS = "CREATE TABLE mails (id INTEGER PRIMARY KEY AUTOINCREMENT, pid INTEGER DEFAULT '0', from_id INTEGER, to_id INTEGER, subject TEXT, body TEXT, datetime TEXT, read INTEGER);";
  </code></pre>
  
  <p>Error:</p>
  
  <p><img src="https://i.stack.imgur.com/xPjoE.png" alt="alt text"></p>
  
  <p><a href="http://variable3.com/files/screenshots/2010-12-29_1136.png" rel="nofollow noreferrer">http://variable3.com/files/screenshots/2010-12-29_1136.png</a></p>