title: Using sharedPreferences with a material spinner to update activities
body: <p>I found this amazing Material spinner online and I was able to modify it for my code:</p>
  
  <pre><code>&lt;fr.ganfra.materialspinner.MaterialSpinner
          android:id="@+id/spinner"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          app:ms_multiline="false"
          app:ms_baseColor="@color/off"
          app:ms_highlightColor="@color/off"
          app:ms_hintColor="@color/off"
          app:ms_arrowColor="@color/off"
          app:ms_arrowSize="16dp"
          app:ms_alignLabels="false"
          app:ms_floatingLabelColor="@color/off"/&gt;
  </code></pre>
  
  <p>so I used sharedPreferences to store whatever value the user chooses from the spinner so when this page is called again, the choice is on the spinner face.
  This is how I add the preferences in the onCreate:</p>
  
  <pre><code> @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.settings);
  
  String[] ITEMS = {"Daily", "Weekly", "Monthly"};
      ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_spinner_item, ITEMS);
      adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
      spinner = (MaterialSpinner)findViewById(R.id.spinner);
      spinner.setAdapter(adapter);
      spinner.setError(null);
  
  spinpref=getSharedPreferences("frequency", MODE_PRIVATE);
              spinedit=spinpref.edit();
              spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                  @Override
                  public void onItemSelected(AdapterView&lt;?&gt; parent, View view, int position, long id) {
                      if (position == 1) {
                          int freq1 = 1;
                          spinedit.putInt("freq", freq1);
                          spinedit.apply();
                      } else if (position == 2) {
                          int freq2 = 2;
                          spinedit.putInt("freq", freq2);
                          spinedit.apply();
                      } else if (position == 3) {
                          int freq3=3;
                          spinedit.putInt("freq", freq3);
                          spinedit.apply();
                      }
                  }
  
                  @Override
                  public void onNothingSelected(AdapterView&lt;?&gt; parent) {
                      int freq0 = 0;
                      spinedit.putInt("freq", freq0);
                      spinedit.apply();
                  }
  
              });
              finish();
  }
  </code></pre>
  
  <p>then in the onResume, I do this:</p>
  
  <pre><code>@Override
  protected void onResume() {
  
      spinpref=getSharedPreferences("frequency",MODE_PRIVATE);
      int num=spinpref.getInt("freq", 0);
      spinner.setSelection(num);
  }
  </code></pre>
  
  <p>But my spinner just shows the first value, how could I do this to make it work? I don't think the sharedPrefs is wrong, but it may be the onItemSelected() and i'm not sure how else I could do this? 
  PS: I tried replacing this line for each of the positions as</p>
  
  <pre><code>spinedit.putInt("freq", position);
  </code></pre>
  
  <p>instead of what I have there right now:</p>
  
  <pre><code>spinedit.putInt("freq", freq);
  </code></pre>
  
  <p>but that didn't work either.
  Any ideas or material anyone is willing to bring to light for me please? I would appreciate it very much</p>