How to perform an update on a Spinner from the EditText data in Android

0

I have a Spinner that is being populated with SQLite data, I want to get this data, edit it and update it

My method of the SpinnerDataBase class (responsible for the Spinner database)

public void alteraRegistroSpinner (int id, String label){
        ContentValues values;
        String where;

        db = this.getWritableDatabase();

        where = SpinnerDatabase.KEY_ID + "=" +id;

        values = new ContentValues();
        values.put(SpinnerDatabase.KEY_NAME,label);

        db.update(SpinnerDatabase.TABLE_LABELS,values,where,null);
        db.close();
    }

Method in my Fragment that throws Spinner data in EditText

spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {

                String passaValor = spinner.getItemAtPosition(position).toString();
                editarAssunto.setText(passaValor);

            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });

I need to call inside the onItemSelectedListener? How do I pass the new data to DB?

    
asked by anonymous 19.09.2017 / 21:38

0 answers