title: How can i update a field of my spinner with user input in EditText
body: <p>I have a SQLite Database with is populating my Spinner.
  The "add" functionality it's working good! What I wanna do is when user clicks in on spinner item he can change the following field and update in the Database</p>
  
  <p>My Spinner database</p>
  
  <pre><code>public class SpinnerDatabase extends SQLiteOpenHelper{
      private SQLiteDatabase db;
  
      private static final int DATABASE_VERSION = 1;
      private static final String DATABASE_NAME = "spinnerDB";
      private static final String TABLE_LABELS = "labels";
      private static final String KEY_ID = "id";
      private static final String KEY_NAME = "name";
  
      public SpinnerDatabase(Context context) {
          super(context,DATABASE_NAME,null,DATABASE_VERSION);
      }
  
      @Override
      public void onCreate(SQLiteDatabase db) {
          String CREATE_CATEGORIES_TABLES = "CREATE TABLE " +
                  TABLE_LABELS + "(" + KEY_ID + " INTEGER PRIMARY KEY AUTOINCREMENT,"+
                  KEY_NAME + " TEXT)";
          db.execSQL(CREATE_CATEGORIES_TABLES);
  
      }
  
      @Override
      public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
          db.execSQL("DROP TABLE IF EXISTS " + TABLE_LABELS);
          onCreate(db);
      }
  
      public void insertLabel(String label){
          SQLiteDatabase db = this.getWritableDatabase();
  
          ContentValues values = new ContentValues();
          values.put(KEY_NAME,label);
  
          db.insert(TABLE_LABELS,null,values);
          db.close();
      }   
      public List&lt;String&gt; getAllLabels(){
          List&lt;String&gt; labels = new ArrayList&lt;String&gt;();
          String selectQuery = "SELECT * FROM "+ TABLE_LABELS;
          SQLiteDatabase db = this.getReadableDatabase();
          Cursor cursor = db.rawQuery(selectQuery,null);
          if (cursor.moveToFirst()){
              do{
                  labels.add(cursor.getString(1));
              }while (cursor.moveToNext());
          }
  
          cursor.close();
          db.close();
          return labels;
      }
  
  
      public void updateSpinner (int id, String label){
          ContentValues values;
          String where;
  
          db = this.getWritableDatabase();
  
          where = KEY_ID + " = " +id;
  
          values = new ContentValues();
          values.put(KEY_NAME,label);
  
          db.update(TABLE_LABELS,values,where,null);
          db.close();
      }
  }
  </code></pre>
  
  <p>The problem is when I click the button to update, it doesn't do anything! And just update the other item (if I have more the one).
  This is my method in my fragment that list all the entries:</p>
  
  <pre><code> private void loadSpinnerData (){
          SpinnerDatabase db = new SpinnerDatabase(getActivity().getApplicationContext());
  
          List&lt;String&gt; labels = db.getAllLabels();
  
          ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(getActivity().getApplicationContext(),
                  android.R.layout.simple_spinner_item,labels);
  
          adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
          spinner.setAdapter(adapter);
      }
  </code></pre>
  
  <p>And here the button save that i'm trying to do the update:</p>
  
  <pre><code>btnSave.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  String name = editText.getText().toString();
  
                  if(name.length()&gt;0 &amp;&amp; name != null){
                      int spinnerValue = spinner.getSelectedItemPosition();
                      SpinnerDatabase db = new SpinnerDatabase(getActivity().getApplicationContext());
                      db.updateSpinner(spinnerValue,name);
              }
          });
  </code></pre>