title: Android: Get Dataset ID from cursor populated Spinner
body: <p>I'm using a spinner to let the user choose a database relation (1:n) in an create and update dialog. Populating the spinner with a database cursor works fine:</p>
  
  <pre><code>    //set up spinner
      Spinner spinner = (Spinner) dialog.findViewById(R.id.field_task_fkbudget);
      //set up cursor
      budgetsData = new TBTsqlHelperBudgets(this);        
  SQLiteDatabase db = budgetsData.getReadableDatabase();
      Cursor c2 = db.query(TBTsqlHelperBudgets.TABLE,null,null,null,null,null,null);        
      c2.moveToFirst();
      // populate spiner
      SimpleCursorAdapter adapter2 = new SimpleCursorAdapter(this, android.R.layout.simple_spinner_item, c2, new String[] {TBTsqlHelperTasks.KEY_NAME}, new int[] {android.R.id.text1});
      adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
      spinner.setAdapter(adapter2);
      spinner.setSelection(0);
  </code></pre>
  
  <p>My problem now is saving the choice to the database. I tried to use:</p>
  
  <pre><code>    ... 
      caller.updateTask(task_id, field_name.getText().toString(), s.getSelectedItemPosition());
      ...
  </code></pre>
  
  <p>but this gives me the datasets position within the spinner. What I need is the content of the field BaseColumns._ID of the cursor element that has been chosen in the spinner.</p>
  
  <p>Is there a better way to receive this than doing another select with a string match on the database?</p>