title: Get Spinner position and get it selected
body: <p>I need save in prefs the value or position of my Spinner and when the users access to settings activity show it as selected. But I'm having troubles.My prob is in the for to get the item position and use it as selected on the list.</p>
  
  <p>Spinner code</p>
  
  <pre><code>    Spinner spinner = (Spinner) findViewById(R.id.spinner1);
      ArrayAdapter&lt;CharSequence&gt; adapter = ArrayAdapter.createFromResource(
              this, R.array.spinner, android.R.layout.simple_spinner_item);
      adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
      spinner.setAdapter(adapter);
  
      spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
  
          public void onItemSelected(AdapterView&lt;?&gt; parent, View view,
                  int position, long id) {
  
              item = parent.getSelectedItem().toString();
              Log.v("SPINNER", item);
  
               //SAVE PREFS WITH SPINNER VALUE
               SharedPreferences prefs;
               prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
               SharedPreferences.Editor prefEditor = prefs.edit();
               prefEditor.putString("spinner",item);
               prefEditor.commit();
               //RETREIVE SPINNER VALE PREFS
               String spinner=PreferenceManager
                       .getDefaultSharedPreferences(getBaseContext())
                       .getString("spinner","");
  //CHECK 
  for(int i=0;i&lt;9;i++)
  if(spinner.equals(parent.getSelectedItem().toString())){
       spinner.setSelection(parent.getItemAtPosition(position));
       break;
  }
  
          }
  
          public void onNothingSelected(AdapterView&lt;?&gt; parent) {
              //String str = "Selecciona";
          }
  
      });
  </code></pre>
  
  <p>XML</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;resources&gt;
      &lt;string-array name="spinner"&gt;
          &lt;item&gt;10:00&lt;/item&gt;
          &lt;item&gt;11:00&lt;/item&gt;
          &lt;item&gt;12:00&lt;/item&gt;
          &lt;item&gt;13:00&lt;/item&gt;
          &lt;item&gt;14:00&lt;/item&gt;
          &lt;item&gt;15:00&lt;/item&gt;
          &lt;item&gt;16:00&lt;/item&gt;
          &lt;item&gt;17:00&lt;/item&gt;
          &lt;item&gt;18:00&lt;/item&gt;
          &lt;item&gt;19:00&lt;/item&gt;
          &lt;item&gt;20:00&lt;/item&gt;
          &lt;item&gt;21:00&lt;/item&gt;
          &lt;item&gt;22:00&lt;/item&gt;
          &lt;item&gt;23:00&lt;/item&gt;
          &lt;item&gt;24:00&lt;/item&gt;
      &lt;/string-array&gt;
  &lt;/resources&gt;
  </code></pre>