title: How to know which user is trying to Sign-in?
body: <p><a href="https://i.stack.imgur.com/JETFS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JETFS.png" alt="enter image description here"></a></p>
  
  <p>Users are created using Email and Password. This is how I do the Sign-up: </p>
  
  <pre><code>    mSignup.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
  
              mEmailStr = removeSpaces(mEmail.getText().toString());
              mPasswordStr = mPassword.getText().toString();
              mUsernameStr = mUsername.getText().toString();
              mIsSgl = mSglCheckBox.isChecked();
              mUsernameStr=mUsername.getText().toString();
              final User mUser = new User();
              mUser.setEmail(mEmailStr);
              mUser.setPassword(mPasswordStr);
              mUser.setIsSgl(mIsSgl);
              mUser.setStudyGroupName(mStudyGroupName);
              mUser.setUsername(mUsernameStr);
              FirebaseAuth.getInstance().createUserWithEmailAndPassword(mUser.getEmail(), mUser.getPassword()).addOnCompleteListener(new OnCompleteListener&lt;AuthResult&gt;() {
                  @Override
                  public void onComplete(Task&lt;AuthResult&gt; task) {
  
  
                      if (task.isSuccessful()) {
                          Toast.makeText(getActivity(), "Sucsses", Toast.LENGTH_SHORT).show();
                          generateUser(mUser);
                          startActivity(new Intent(getActivity(), MainActivity.class));
                      } else {
                          Toast.makeText(getActivity(), "not Sucsses", Toast.LENGTH_SHORT).show();
                      }
                  }
              });
  
  
  
          }
      });
  </code></pre>
  
  <p>This is how I push the data into database:</p>
  
  <pre><code> public void generateUser(User user)
    {
  
      FirebaseDatabase database = FirebaseDatabase.getInstance();
      DatabaseReference users;
      if(user.getIsSgl())
      {
          users = database.getReference(user.getStudyGroupName()).child("SGL");
      }
      else
      {
          users = database.getReference(user.getStudyGroupName()).child("Student");
      }
  
      users.push().setValue(user);
  
  }
  </code></pre>
  
  <p>This is how I Sign-in:</p>
  
  <pre><code>mSignin.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
  
              mEmailStr = SignupActivityFragment.removeSpaces(mEmail.getText().toString());
              mPasswordStr = mPassword.getText().toString();
  
              mAuth.signInWithEmailAndPassword(mEmailStr, mPasswordStr).addOnCompleteListener(getActivity(), new OnCompleteListener&lt;AuthResult&gt;() {
                  @Override
                  public void onComplete(Task&lt;AuthResult&gt; task) {
                      if (task.isSuccessful()){
  
  
                          FirebaseDatabase database = FirebaseDatabase.getInstance();                            
                          // thats not worked for me
                          database.getReference("StudyGroups").child("Student").orderByChild("email").equalTo(mEmailStr).addListenerForSingleValueEvent(new ValueEventListener() {
                              @Override
                              public void onDataChange(DataSnapshot dataSnapshot) {
                                  for (DataSnapshot childSnapShot : dataSnapshot.getChildren()) {
                                      userKey = childSnapShot.getKey();
                                  }
  
                                  Toast.makeText(getContext(),"Userkey: " + userKey,Toast.LENGTH_LONG).show();
                                  Log.v("himaAbousalem",userKey);
                              }
  
                              @Override
                              public void onCancelled(DatabaseError databaseError) {
  
                              }
                          });
                          Toast.makeText(getActivity(), "Sucsses ", Toast.LENGTH_SHORT).show();
                          startActivity (new Intent(getActivity(),Controller.class));
                      }else {
                          Toast.makeText(getActivity(), "not sucsses", Toast.LENGTH_SHORT).show();
                      }
  
                  }
              });
          }
      });
  </code></pre>
  
  <p>I want to query the database so that when a user signs-in by Email and password, it returns all the data of that user from the database.</p>
  
  <p>How can I make the key of <code>userId</code> in Auth equal to the <code>userId</code> in database and how do I use that feature?</p>