title: How to increment count when start activity on button click in Android?
body: <p>I have two activities.  Whenever I go from the 1st activity to the 2nd activity count should be incremented on button click.</p>
  
  <p>Here is the code in the 1st activity code for starting the 2nd activity:</p>
  
  <pre><code>imgCreatePost.setVisibility(View.VISIBLE);
              imgCreatePost.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View v)
                  {
                      Intent i = new Intent(1st.this, 2nd.class);
                      //finish();
                      startActivity(i);
  
                  }
              });
  </code></pre>
  
  <p>Here is where the count is incremented <code>onCreate()</code> in the 2nd activity:</p>
  
  <pre><code>  visitCount = 0;
    public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.add_post);
          int increament = visitCount +=1;
          Log.e(" increament ", " = " + increament);
  
         if (visitCount == 10) {
              visitCount = 0;
            }}
  
    imgBackButton.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v)
              {
                  Intent i = new Intent(2nd.this , 1st.class);
                  //finish();
                  //startActivityForResult(i, 9);
                  startActivity(i);
                  overridePendingTransition(R.anim.back, R.anim.back_out);
  
              }
          });
  </code></pre>
  
  <p>Whenever I come to the 2nd activity from the 1st activity increment is always 1. Why doesn't it increment one by one? </p>