title: Android Listview onListItemClick get Sqlite Id
body: <p>I am simply displaying a list from sqlite table. I have not used any BDHelper class. With this code only how can i get id.</p>
  
  <p><img src="https://i.stack.imgur.com/SrE4B.png" alt="enter image description here">
  <br/>When i click on 1st Item, it shows 0 where as in table it's id is 1. Below is my code. </p>
  
  <pre><code>SQLiteDatabase myDB;
          try {
              myDB = openOrCreateDatabase(DB_NAME,
                      SQLiteDatabase.CREATE_IF_NECESSARY, null);          
              myDB.execSQL("create table if not exists " + COUNTRY_TABLE
              + "(country_id INTEGER PRIMARY KEY,"
              + "country_title text," 
              + "country_status int(11));");          
  
               /*myDB.execSQL("insert into " + COUNTRY_TABLE +" values "+
               "(null,'India',1)," +
               "(null,'China',1)," +
               "(null,'Australia',1)," +
               "(null,'Japan',1)," +
               "(null,'Germany',1)");*/
  
  
              Cursor c = myDB.rawQuery("select country_id,country_title from "
                      + COUNTRY_TABLE + " where country_status=1", null);
              if (c != null) {
                  if (c.moveToFirst()) {
                      do {
                          int id = c.getInt(c.getColumnIndex("country_id"));
                          String name = c.getString(c.getColumnIndex("country_title"));                       
                          clist.add(id + ") " + name);
                      } while (c.moveToNext());
                      //int itemcount = clist.size();
                      //Toast.makeText(MainActivity.this, itemcount, Toast.LENGTH_LONG).show();
                      setListAdapter(new ArrayAdapter&lt;String&gt;(this,android.R.layout.simple_list_item_1, clist));
                  }
              }
  
          } catch (SQLiteException se) {
              Toast.makeText(MainActivity.this, se.getMessage().toString(),Toast.LENGTH_LONG).show();
          }
  
  protected void onListItemClick(ListView l, View v, int position, long id) {
          // TODO Auto-generated method stub
          super.onListItemClick(l, v, position, id);
          Toast.makeText(MainActivity.this,String.valueOf(id),Toast.LENGTH_LONG).show();
      }
  </code></pre>
  
  <p>Please suggest what should i do to get the id fron table and not the position. </p>