0
I have a Spinner that is being filled with Sqlite data, I want to take this data, edit them and update them
My Spinnerdatabase class method (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 playing Spinner dice 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 the BD?
What list or array is with the database values ?
– Dev
Essa aqui: private void loadSpinnerData (){
 SpinnerDatabase db = new SpinnerDatabase(getActivity().getApplicationContext());

 List<String> labels = db.getAllLabels();

 ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity().getApplicationContext(), android.R.layout.simple_spinner_item,Labels); Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(Adapter); }
– Vinícius Ghietti