title: ListView use SimpleCursorAdapter get id error
body: <p>This my SQlite Table
  <img src="https://i.stack.imgur.com/XdJPF.png" alt="enter image description here"></p>
  
  <p>I want to use <code>onItemClick</code> to get id.
  This is my code:</p>
  
  <pre><code>public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int arg2,long arg3) {                               
         // TODO Auto-generated method stub
  
         int id_To_Search = (int)arg3;
         //Toast.makeText(getActivity(), arg0.getItemAtPosition(arg2).getLong(0), Toast.LENGTH_LONG).show();
         Toast.makeText(getActivity(), "ID: " + arg3 , Toast.LENGTH_LONG).show();
  
  
         Bundle dataBundle = new Bundle();
         dataBundle.putInt("id", id_To_Search);
  
         Intent intent = new Intent(getActivity().getApplicationContext(),DisplayContact1.class);
  
         intent.putExtras(dataBundle);
         startActivity(intent);
  }
  </code></pre>
  
  <p>but <code>onItemClick</code> is passing the database row "name".
  HELP ME?</p>
  
  <p>This is my DBHelper</p>
  
  <pre><code>public class DBHelper extends SQLiteOpenHelper {
  
  public static final String DATABASE_NAME = "MyDBName.db";
  public static final String CONTACTS_TABLE_NAME = "contacts";
  public static final String CONTACTS_COLUMN_NAME = "name";
  public static final String CONTACTS_COLUMN_EMAIL = "email";
  public static final String CONTACTS_COLUMN_STREET = "street";
  public static final String CONTACTS_COLUMN_CITY = "place";
  public static final String CONTACTS_COLUMN_PHONE = "phone";
  public static final String CONTACTS_COLUMN_INCOME = "income";
  public static final String CONTACTS_COLUMN_LEGEND = "legend";
  public static final String CONTACTS_COLUMN_DATE = "date";
  
  
  
  private HashMap hp;
  SQLiteDatabase db = null;
  
  
  
  public DBHelper(Context context) {
      super(context, DATABASE_NAME , null, 1);
  }
  
  @Override
  public void onCreate(SQLiteDatabase db) {
      // TODO Auto-generated method stub
      db.execSQL(
              "create table contacts " + "(_id integer primary key, name text,phone text,email text, street text,place text)"
      );
      db.execSQL("create table contacts2 " + "(id integer primary key,income text, legend text, date text)");
  
  
  }
  
  @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
      // TODO Auto-generated method stub
      db.execSQL("DROP TABLE IF EXISTS contacts");
      db.execSQL("DROP TABLE IF EXISTS contacts2");
      onCreate(db);
  }
  
  public Cursor select()
  {
      SQLiteDatabase db = this.getReadableDatabase();
      Cursor cursor = db.query("contacts", null, null, null, null, null, null);
      return cursor;
  }
  
  public Cursor select2()
  {
      SQLiteDatabase db = this.getReadableDatabase();
      Cursor cursor = db.query("contacts2", null, null, null, null, null, null);
      return cursor;
  }
  
  
  public boolean insertContact (String name, String phone, String email, String street,String place) {
      SQLiteDatabase db = this.getWritableDatabase();
      ContentValues contentValues = new ContentValues();
      contentValues.put("name", name);
      contentValues.put("phone", phone);
      contentValues.put("email", email);
      contentValues.put("street", street);
      contentValues.put("place", place);
      db.insert("contacts", null, contentValues);
      return true;
  }
  
  public boolean insertContact2 (String income, String legend, String date) {
      SQLiteDatabase db = this.getWritableDatabase();
      ContentValues contentValues = new ContentValues();
      contentValues.put("income", income);
      contentValues.put("legend", legend);
      contentValues.put("date", date);
      db.insert("contacts2", null, contentValues);
      return true;
  }
  
  public Cursor getData(int id) {
      SQLiteDatabase db = this.getReadableDatabase();
      Cursor res =  db.rawQuery( "select * from contacts where id="+id+"", null );
      return res;
  }
  
  public Cursor getData2(int id) {
      SQLiteDatabase db = this.getReadableDatabase();
      Cursor res =  db.rawQuery( "select * from contacts2 where id="+id+"", null );
      return res;
  }
  
  
  
  
  public int numberOfRows(){
      SQLiteDatabase db = this.getReadableDatabase();
      int numRows = (int) DatabaseUtils.queryNumEntries(db, CONTACTS_TABLE_NAME);
      return numRows;
  }
  
  
  
  public boolean updateContact (Integer id, String name, String phone, String email, String street,String place) {
      SQLiteDatabase db = this.getWritableDatabase();
      ContentValues contentValues = new ContentValues();
      contentValues.put("name", name);
      contentValues.put("phone", phone);
      contentValues.put("email", email);
      contentValues.put("street", street);
      contentValues.put("place", place);
      db.update("contacts", contentValues, "id = ? ", new String[] { Integer.toString(id) } );
      return true;
  }
  
  public boolean updateContact2 (Integer id, String income, String legend, String date) {
      SQLiteDatabase db = this.getWritableDatabase();
      ContentValues contentValues = new ContentValues();
      contentValues.put("income", income);
      contentValues.put("legend", legend);
      contentValues.put("date", date);
      db.update("contacts2", contentValues, "id = ? ", new String[] { Integer.toString(id) } );
      return true;
  }
  
  public Integer deleteContact (Integer id) {
      SQLiteDatabase db = this.getWritableDatabase();
      return db.delete("contacts", "id = ? ", new String[] { Integer.toString(id) });
  
  }
  
  public Integer deleteContact2 (Integer id) {
      SQLiteDatabase db = this.getWritableDatabase();
      return db.delete("contacts2", "id = ? ", new String[] { Integer.toString(id) });
  
  }
  
  public ArrayList&lt;String&gt; getAllCotacts() {
      ArrayList&lt;String&gt; array_list = new ArrayList&lt;String&gt;();
  
      SQLiteDatabase db = this.getReadableDatabase();
      Cursor res =  db.rawQuery( "select * from contacts", null );
      res.moveToFirst();
  
      while(res.isAfterLast() == false){
          array_list.add(res.getString(res.getColumnIndex(CONTACTS_COLUMN_NAME)));
          res.moveToNext();
      }
      return array_list;
  }
  
  public ArrayList&lt;Float&gt; getFloat() {
      ArrayList&lt;Float&gt; array_list = new ArrayList&lt;Float&gt;();
  
      SQLiteDatabase db = this.getReadableDatabase();
      Cursor res =  db.rawQuery( "select * from contacts", null );
      res.moveToFirst();
  
      while(res.isAfterLast() == false){
          array_list.add(res.getFloat(res.getColumnIndex(CONTACTS_COLUMN_NAME)));
          res.moveToNext();
      }
      return array_list;
  }
  
  public ArrayList&lt;String&gt; getItem() {
      ArrayList&lt;String&gt; array_list = new ArrayList&lt;String&gt;();
  
      SQLiteDatabase db = this.getReadableDatabase();
      Cursor res =  db.rawQuery( "select * from contacts", null );
      res.moveToFirst();
  
      while(res.isAfterLast() == false){
          array_list.add(res.getString(res.getColumnIndex(CONTACTS_COLUMN_PHONE)));
          res.moveToNext();
      }
      return array_list;
  }
  
  public ArrayList&lt;String&gt; getAllCotacts2() {
      ArrayList&lt;String&gt; array_list = new ArrayList&lt;String&gt;();
  
      SQLiteDatabase db = this.getReadableDatabase();
      Cursor res =  db.rawQuery( "select * from contacts2", null );
      res.moveToFirst();
  
      while(res.isAfterLast() == false){
          array_list.add(res.getString(res.getColumnIndex(CONTACTS_COLUMN_INCOME)));
          res.moveToNext();
      }
      return array_list;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>How can I do get id?</p>
  
  <p>ps. I use <code>cursor.getString( cursor.getColumnIndex("id")</code> but the error is:
  <code>Couldn't read row 2, col -1 from CursorWindow.</code></p>