title: How to increment number in firebase
body: <p>I've edited the code. It works. It increment the counter in firebase. But there is 1 problem. Whenever I restart the app (after clear recent app), the increment starts over. It does not continue from previous number.</p>
  
  <p>public class MainActivity extends AppCompatActivity {</p>
  
  <pre><code>Button bNext;
  long count;
  
  DatabaseReference mRootRef = FirebaseDatabase.getInstance().getReference();
  DatabaseReference mCounterRef = mRootRef.child("counter");
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      bNext = (Button) findViewById(R.id.bNext);
  
      bNext.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              mCounterRef.setValue(++count);
          }
      });
  
  }
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/Q4ICA.png" rel="nofollow noreferrer">this is my database</a></p>