title: load from spinner sqlite with text and value
body: <p>i have a spinner load data to sqlite</p>
  
  <p>i have field id and field name in database.</p>
  
  <pre><code>private void loadSpinnerDataHama() {
          // database handler
          DatabaseSpinner db = new DatabaseSpinner(getApplicationContext()); 
          // Spinner Drop down elements
          List&lt;String&gt; lables = db.getAllLabels();
          // Creating adapter for spinner
          ArrayAdapter&lt;String&gt; dataAdapter = new ArrayAdapter&lt;String&gt;(this,
          android.R.layout.simple_spinner_item, lables);
          // Drop down layout style - list view with radio button
          dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
          // attaching data adapter to spinner
          spin2.setAdapter(dataAdapter);
      }
  
      public List&lt;String&gt; getAllLabels(){
      List&lt;String&gt; labels = new ArrayList&lt;String&gt;();
      // Select All Query
      String selectQuery = "SELECT  * FROM " + TABLE_LABELS;
  
      SQLiteDatabase db = this.getReadableDatabase();
      Cursor cursor = db.rawQuery(selectQuery, null);
  
      // looping through all rows and adding to list
      if (cursor.moveToFirst()) {
          do {
              labels.add(cursor.getString(1));
          } while (cursor.moveToNext());
      }
  
      // closing connection
      cursor.close();
      db.close();
  
      // returning lables
      return labels;
  }
  </code></pre>
  
  <p>and the result is</p>
  
  <p>USA -> value is "USA"</p>
  
  <p>France -> value is "France"</p>
  
  <p>when i change the code <code>labels.add(cursor.getString(1));</code> to <code>labels.add(cursor.getString(0));</code></p>
  
  <p>and the result is</p>
  
  <p>1 -> value is "1"</p>
  
  <p>2 -> value is "2"</p>
  
  <p>i try with <code>int position2 = spin2.getSelectedItemPosition()+1;</code> but the value is  id/position of spinner , not the id of database.</p>
  
  <p>how to display field name on spinner. but the value is id of name</p>
  
  <p>Example: The spinner display:</p>
  
  <p>USA -> value is "1"</p>
  
  <p>France -> value is "2"</p>
  
  <p>BR</p>
  
  <p>Alex</p>