How to get id from selecting its value in spinner? <p>I want to get the id of the value selected in the spinner who's value is derived from Sqlite.</p> <p>My table in Sqlite is </p> <p>CITY_ID CITY_NAME <BR></p> <p>8 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BOMBAY <BR> 9 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NEW DELHI <BR> 10 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MADRAS <BR> 11 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CALCUTTA <BR> 12 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BANGLORE <BR> 13 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AHMEDABAD <BR> 14 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; JAIPUR <BR> 15 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CHANDIGARH <BR> 16 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SIMLA <BR> 17 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LUCKNOW <BR> 18 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PATNA <BR> 19 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BHOPAL <BR> 20 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NAGPUR <BR></p> <p>My Database Connector code is</p> <pre><code>public List&lt;String&gt; getCity(){ List&lt;String&gt; labels = new ArrayList&lt;String&gt;(); String selectQuery = "SELECT CITY_ID, CITY_NAME FROM city_list"; Log.d("Destination Country Query", selectQuery); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(selectQuery, null); if (cursor.moveToFirst()) { do { labels.add(cursor.getString(1)); } while (cursor.moveToNext()); } cursor.close(); db.close(); return labels; } </code></pre> <p>My implementation is </p> <pre><code>city = (Spinner) findViewById(R.id.city); loadCityData(); private void loadCityData() { DatabaseConnector db = new DatabaseConnector(getApplicationContext()); List&lt;String&gt; lables = db.getCity(); ArrayAdapter&lt;String&gt; dataAdapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_spinner_item, lables); dataAdapter .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); city.setAdapter(dataAdapter); } </code></pre> <p>Now by selecting the City in the spinner. I want to get the id from the SQlite table.</p> <p>Can some one guide me to achieve this.</p> <p>Thanks in advance.</p> <p>Regards, Dinesh</p>