title: The Activity restart after saving data in Firebase
body: <p>Im trying to save user information in Firebase Database but a strange behavior happens that make the Save button to restart the same activity not the Intent that i made for the next activity .</p>
  
  <pre><code> public void userData () {
      user.setFName(Fname.getText().toString());
      user.setLName(Lname.getText().toString());
      user.setEmail(Email.getText().toString());
      user.setAddress(userAddress.getText().toString());
      user.setPassword(UserInfo.getString("Password", ""));
      user.setID(CicID.getText().toString());
      user.setUsername(Usnm.getText().toString());
      if (bAdmn.isChecked()) user.setMajor("Business Administrator");
      if (BTech.isChecked()) user.setMajor("Business Tech");
      if (masscom.isChecked()) user.setMajor("Mass Com");
      if (Eng.isChecked()) user.setMajor("Engineering");
  
      final String us = user.getUsername();
      Log.i("Username", us);
      MyDatabase1.child("USERS").child(us).setValue(user);
      Intent i = new Intent(getApplicationContext() , chooseCoursesActivity.class);
      startActivity(i);
  
  }
  </code></pre>
  
  <p>that is the method for save button , Note that i want to update the user information in a profile Activity if the user wants to change his First name or Last name or something .
  But after Clicking save button , the data is saved correctly but the intent never done . it recreate the same Activity .
  in the Login activity there is aLogin button which checks username and password then attempt to log in based on data ,if login successful it goes to that Profile Activity .
  Save button in Profile Activity re Do the method in Login button in Login Activity which checks everything and goes to Profile Activity which what causing the Re Create Problem .
  Here is the code for login button :</p>
  
  <pre><code>    MyDatabase = FirebaseDatabase.getInstance().getReference();
      MyDatabase.child("USERS").addValueEventListener(new ValueEventListener() {
          @Override
          public void onDataChange(DataSnapshot dataSnapshot) {
              boolean exists = false;
  
              for (DataSnapshot child : dataSnapshot.getChildren()) {
                  final Map&lt;String, Object&gt; model = (Map&lt;String, Object&gt;) child.getValue();
  
                  if (model.get("username").equals(Username.getText().toString())) {
                      exists = true;
                      Log.i("USername"," Correct");
  
  
                      if(exists){
                          MyDatabase.child("USERS").orderByChild("username").equalTo(Username.getText().toString())
  
                                  .addListenerForSingleValueEvent(new ValueEventListener() {
                              @Override
                              public void onDataChange(DataSnapshot dataSnapshot) {
  
                                  for (DataSnapshot child :dataSnapshot.getChildren()){
                                      Log.i("Password",child.getValue().toString());
                                     Log.i( "Password",child.child("password").toString());
                                      if(password.getText().toString().equals(child.child("password").getValue())){
                                          Log.i("LOGIN","Success");
                                           loginsuccessful = true ;
  
                                      if(loginsuccessful){
  
                                          saveCredntials(Username.getText().toString(),password.getText().toString());
  
  
                                          Intent i2 = new Intent(getApplicationContext(), ProfileActivity.class);
                                          i2.putExtra("loginStats",IsLoggedIn);
                                          i2.putExtra("Username",Un);
  
                                          i2.putExtra("Password",Pw);
  
  
                                          startActivity(i2);
                                          finish();}
                                      }else{
                                          Log.i("LOGIN","Failed");
                                          loginsuccessful= false ;
  
                                      }
  
                                  }
  
                              }
  
                              @Override
                              public void onCancelled(DatabaseError databaseError) {
                                              Toast.makeText(getApplicationContext(),"Error",Toast.LENGTH_LONG).show();
                              }
                          });
                      }
                      break;
  
                  }else {
                      Log.i("LOGIN","FAiled");
  
                  }
  
              }
          }
          @Override
          public void onCancelled(DatabaseError databaseError) {
  
          }
      });
  }
  </code></pre>
  
  <p>Sorry for making this too long but i dont know the problem .</p>