I'm populating a spinner with a number of records from my SQlite database using the following code:
DBHelper db = new DBHelper(getBaseContext()); Cursor cursor_clients = db.select("clients", "_id, name", "ORDER BY name"); // table, fields, filter/order String[] columns = new String[] { "name" }; int[] to = new int[] { android.R.id.text1 }; SimpleCursorAdapter mAdapter = new SimpleCursorAdapter(this, android.R.layout.simple_spinner_item, cursor_clients, columns, to, 0); mAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); Spinner spnClients = (Spinner) findViewById(R.id.spnClients); spnClients.setAdapter(mAdapter); It works great, and I can use
spnAcademias.getSelectedItemId();
To get the _id of the selected record. My problem is: How to select an item on this spinner by the _id?
I have the _id of the row I want, I want it to show this row selected, and not the first row coming from the query.