title: When I try to save details of user in a class before loggin him using Firebase its giving me Error
body: <p>I'm working on a project in which I have to save details of the user before logging him/her in her account so that I don't have to fetch his/her detail again and can refer to that class whenever I need their details. It's displaying the toast "Error occurred ! please login again." which means null value or false is being returned. Also after I close the app and open again its moving to next Activity.</p>
  
  <p><a href="https://i.stack.imgur.com/vOX2p.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vOX2p.png" alt="Screenshot of database"></a></p>
  
  <p>signintouserbycredential method</p>
  
  <pre><code> private void signInTheUserByCredential(PhoneAuthCredential credential)
      {
          firebaseAuth=FirebaseAuth.getInstance();
  
          firebaseAuth.signInWithCredential(credential).addOnCompleteListener(Login_student.this, new OnCompleteListener&lt;AuthResult&gt;() {
              @Override
              public void onComplete(@NonNull Task&lt;AuthResult&gt; task) {
                  if(task.isSuccessful())
                  {
                      String curr_user_str=task.getResult().getUser().getUid();
                      //Store user data in HelperClass for future use
                      if((curr_user_str.isEmpty())&amp;&amp;(storeUserInfoInHelperClass(curr_user_str)))
                      {
                          Toast.makeText(Login_student.this, "Login Successful", Toast.LENGTH_SHORT).show();
                          startActivity(new Intent(Login_student.this, Home_page.class));
                          if (android.os.Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.JELLY_BEAN)
                              finishAffinity();
                      }
                      else
                      {
                          Toast.makeText(Login_student.this,"Error occurred ! Please login again.",Toast.LENGTH_SHORT).show();
                      }
  
                  }
                  else
                  {
                      Toast.makeText(Login_student.this, task.getException().getMessage(), Toast.LENGTH_SHORT).show();
                  }
  
              }
          });
      }
  </code></pre>
  
  <p>storeInfoinHelperClass method</p>
  
  <pre><code>int flag=0;// to check if data is stored and if it is stored return true
      static HelperClass data;
      public boolean storeUserInfoInHelperClass(String curr_user_str) {
              reff = FirebaseDatabase.getInstance().getReference("userdetails");
              reff.child(curr_user_str).addValueEventListener(new ValueEventListener() {
                  @Override
                  public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
                      if (data != null) {
                          data = dataSnapshot.getValue(HelperClass.class);
                          flag=1;
                      } else {
                          flag=0;
                      }
  
                  }
  
                  @Override
                  public void onCancelled(@NonNull DatabaseError databaseError) {
  
                  }
              });
              if(flag==1)
                  return true;
              else
                  return false;
  
      }
  </code></pre>