My goal is decrement value "quantity" after click on button "Save". Error will occur when I call function updateTraining from onClick, because passing arguments are null. So my question is How I should correctly pass values from database to updateTraining and decrement quantity value.

Below my code:

```
public class Activity12 extends AppCompatActivity implements View.OnClickListener{

ListView listViewTraining;
int quantity;
String id;
List<AddTraining> trainingList;
Button buttonUpdate;

DatabaseReference datababaseTraining;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_12);

    datababaseTraining = FirebaseDatabase.getInstance().getReference("Event");

    listViewTraining = (ListView) findViewById(R.id.listViewTraining);
    trainingList = new ArrayList<>();

    listViewTraining.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener(){
        @Override
        public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {
            AddTraining addTraining = trainingList.get(i);

            showUpdateDialog(addTraining.getPlace(), addTraining.getDate(), addTraining.getTime(), addTraining.getQuantity(), addTraining.getId());

            return false;
        }
    });

}

@Override
protected void onStart() {
    super.onStart();

    datababaseTraining.addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {

            trainingList.clear();

            for(DataSnapshot trainingSnapshot : dataSnapshot.getChildren()){

                //First checkout
                AddTraining addtraining = trainingSnapshot.getValue(AddTraining.class);
                System.out.println("check " + addtraining.getPlace());
                System.out.println("check " + addtraining.getTime());
                System.out.println("check " + addtraining.getDate());
                System.out.println("check " + addtraining.getQuantity());
                System.out.println("check " + addtraining.getId());
                trainingList.add(addtraining);

            }

            TrainingList adapter = new TrainingList(Activity12.this, trainingList);
            listViewTraining.setAdapter(adapter);
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {

        }
    });

}

private void showUpdateDialog(String place, String date, int time, int quantity, String id){
    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);

    LayoutInflater inflater = getLayoutInflater();

    System.out.println("checkpoint2 " + quantity);

    final View dialogView = inflater.inflate(R.layout.update_dialog, null);

    dialogBuilder.setView(dialogView);

    final TextView textViewPlace = (TextView) dialogView.findViewById(R.id.textViewPlace2); 
    final TextView textViewDate = (TextView) dialogView.findViewById(R.id.textViewDate2);   
    final TextView textViewTime = (TextView) dialogView.findViewById(R.id.textViewTime2);   
    final TextView textViewQuantity = (TextView) dialogView.findViewById(R.id.textViewQuantity2);
    buttonUpdate = (Button) dialogView.findViewById(R.id.buttonUpdate);
    buttonUpdate.setOnClickListener(this);
    dialogBuilder.setTitle("More details:");

    final AlertDialog alertDialog = dialogBuilder.create();
    alertDialog.show();

    textViewPlace.setText(place);
    textViewDate.setText("Date: " + date);
    textViewTime.setText("Hour: " + String.valueOf(time));
    textViewQuantity.setText("Quantity: " + String.valueOf(quantity));

}

@Override
public void onClick(View view) {
    if (view == buttonUpdate) {
        updateTraining(quantity, id);

    }
}

private void updateTraining( int quantity, String id){
    System.out.println("checkout3 " + quantity);
    DatabaseReference databaseReference = FirebaseDatabase.getInstance().getReference("Event");
    databaseReference.child(id).child("quantity").setValue(quantity-1);

    Toast.makeText(this, "Saved", Toast.LENGTH_LONG).show();

}

```

}

My structure of db is :

[![enter image description here](https://i.stack.imgur.com/iK8nc.png)](https://i.stack.imgur.com/iK8nc.png)