title: Android Firebase database transaction
body: <pre><code>  ATNRef= FirebaseDatabase.getInstance().getReference("AvailableTokenNumber");
                  ATNRef.runTransaction(new Transaction.Handler() {
                      @Override
                      public Transaction.Result doTransaction(MutableData mutableData) {
  
                          if (mutableData.getValue(int.class ) == 0){
                              mutableData.setValue(2);
                              data.tokenNo = 1;
                              return Transaction.success(mutableData);
  
                          }else {
                              data.tokenNo=mutableData.getValue(int.class);
                              mutableData.setValue(data.tokenNo + 1);
                              return Transaction.success(mutableData);
                          }
                      }
  </code></pre>
  
  <p>Whenever the code is run for first time, value of data.tokenNo is 0.
  After that it is updating correctly as per the database value.</p>
  
  <p>I am not able to figure it out what makes the value of data.token = 0 on every first run of the app/code.</p>