title: App crashes when moves from login activity to next activity in onDataChange method
body: <p>The app is to make a person login as admin if he has a registered phone and password
  But when the code retrieves the data in realtime database in firbase 
  I was following firebase tutorial on youtube .<a href="https://www.youtube.com/watch?v=1z2awGCuDdM&amp;list=PLxefhmF0pcPlqmH_VfWneUjfuqhreUz-O&amp;index=9" rel="nofollow noreferrer">https://www.youtube.com/watch?v=1z2awGCuDdM&amp;list=PLxefhmF0pcPlqmH_VfWneUjfuqhreUz-O&amp;index=9</a>
   my loginActivity class is given below</p>
  
  <pre><code>package com.example.clone;
  
  import androidx.annotation.NonNull;
  import androidx.appcompat.app.AppCompatActivity;
  
  import android.annotation.SuppressLint;
  import android.content.Intent;
  import android.os.Bundle;
  import android.text.TextUtils;
  import android.util.Log;
  import android.view.View;
  import android.widget.Button;
  import android.widget.CheckBox;
  import android.widget.EditText;
  import android.widget.TextView;
  import android.widget.Toast;
  
  import com.example.clone.Model.Details;
  import com.example.clone.Prevalent.Prevalent;
  import com.google.firebase.database.DataSnapshot;
  import com.google.firebase.database.DatabaseError;
  import com.google.firebase.database.DatabaseReference;
  import com.google.firebase.database.FirebaseDatabase;
  import com.google.firebase.database.ValueEventListener;
  
  import io.paperdb.Paper;
  
  public class LoginActivity extends AppCompatActivity {
  
  
      private static final String TAG ="Started" ;
      private EditText phoneInput;
      private EditText passwordInput;
      private Button loginBtn;
      private TextView AdminLink, NotAdminLink;
  
  
      private String parentDbName = "Users";
      private CheckBox chkBoxRememberMe;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_login);
  
  
          phoneInput = (EditText) findViewById(R.id.login_phone_number_input);
          passwordInput = (EditText) findViewById(R.id.login_password_input);
          loginBtn = (Button) findViewById(R.id.login_btn);
          AdminLink = (TextView) findViewById(R.id.admin_panel_link);
          NotAdminLink = (TextView) findViewById(R.id.not_admin_panel_link);
  
          chkBoxRememberMe = (CheckBox) findViewById(R.id.remember_me_chbk);
          Paper.init(this);
  
          AdminLink.setOnClickListener(new View.OnClickListener() {
              @SuppressLint("SetTextI18n")
              @Override
              public void onClick(View v) {
                  loginBtn.setText("Login Admin");
                  AdminLink.setVisibility(View.INVISIBLE);
                  NotAdminLink.setVisibility(View.VISIBLE);
                  parentDbName = "Admin";
              }
          });
  
          NotAdminLink.setOnClickListener(new View.OnClickListener() {
              @SuppressLint("SetTextI18n")
              @Override
              public void onClick(View v) {
                  loginBtn.setText("login");
                  AdminLink.setVisibility(View.VISIBLE);
                  NotAdminLink.setVisibility(View.INVISIBLE);
                  parentDbName = "Users";
  
              }
          });
  
  
          loginBtn.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  final String phone = phoneInput.getText().toString();
                  final String password = passwordInput.getText().toString();
                  if (TextUtils.isEmpty(phone)) {
                      phoneInput.setError("Empty");
                  } else if (TextUtils.isEmpty(password)) {
                      passwordInput.setError("Empty");
                  } else {
                      FirebaseDatabase database = FirebaseDatabase.getInstance();
                      DatabaseReference myref = database.getReference();
  
                      if (chkBoxRememberMe.isChecked()) {
                          Paper.book().write(Prevalent.UserPhoneKey, phone);
                          Paper.book().write(Prevalent.UserPasswordKey, password);
                      }
  
                      myref.addListenerForSingleValueEvent(new ValueEventListener() {
                          public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
                              if (dataSnapshot.child(parentDbName).child(phone).exists())
                              {
                                  Details usersData = dataSnapshot.child(parentDbName).child(phone).getValue(Details.class);
  
  
                                  if (usersData.getPhone().equals(phone))
                                   {
                                      if (usersData.getPassword().equals(password)) {
                                          if(parentDbName.equals("Admin")) {
                                              Toast.makeText(LoginActivity.this, "admin welcome!!!", Toast.LENGTH_SHORT).show();
                                              Intent intent = new Intent(LoginActivity.this, AdminCategoryActivity.class);
                                              startActivity(intent);
  
                                          }
                                          else if(parentDbName.equals("Users"))
                                          {
                                              Intent intent = new Intent(LoginActivity.this, HomeActivity.class);
                                              startActivity(intent);
                                          }
  
                                      } else {
                                          Toast.makeText(LoginActivity.this, "Wrong password", Toast.LENGTH_SHORT).show();
                                      }
                                  } else {
                                      Toast.makeText(LoginActivity.this, "Wrong number", Toast.LENGTH_SHORT).show();
                                  }
                              } else {
                                  Toast.makeText(LoginActivity.this, "The input user does not exist", Toast.LENGTH_SHORT).show();
                              }
  
                          }
  
                          @Override
                          public void onCancelled(@NonNull DatabaseError databaseError) {
  
                          }
                      });
                  }
              }
          });
      }
  
  }
  
  </code></pre>
  
  <p>the Details class is</p>
  
  <pre><code>package com.example.clone.Model;
  
  public class Details {
      private String name, password, phone;
  
      public Details() {
      }
  
      public Details(String name, String password, String phone) {
          this.name = name;
          this.password = password;
          this.phone = phone;
      }
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      public String getPassword() {
          return password;
      }
  
      public void setPassword(String password) {
          this.password = password;
      }
  
      public String getPhone() { return phone; }
  
      public void setPhone(String phone) {
          this.phone = phone;
      }
  }
  </code></pre>
  
  <p>the error showing in logcat is.</p>
  
  <pre><code>   --------- beginning of crash
  2020-04-10 14:54:57.443 22896-22896/com.example.clone E/AndroidRuntime: FATAL EXCEPTION: main
      Process: com.example.clone, PID: 22896
      com.google.firebase.database.DatabaseException: Failed to convert value of type java.lang.Long to String
          at com.google.firebase.database.core.utilities.encoding.CustomClassMapper.convertString(com.google.firebase:firebase-database@@16.0.4:413)
          at com.google.firebase.database.core.utilities.encoding.CustomClassMapper.deserializeToClass(com.google.firebase:firebase-database@@16.0.4:199)
          at com.google.firebase.database.core.utilities.encoding.CustomClassMapper.deserializeToType(com.google.firebase:firebase-database@@16.0.4:178)
          at com.google.firebase.database.core.utilities.encoding.CustomClassMapper.access$100(com.google.firebase:firebase-database@@16.0.4:47)
          at com.google.firebase.database.core.utilities.encoding.CustomClassMapper$BeanMapper.deserialize(com.google.firebase:firebase-database@@16.0.4:580)
          at com.google.firebase.database.core.utilities.encoding.CustomClassMapper$BeanMapper.deserialize(com.google.firebase:firebase-database@@16.0.4:550)
          at com.google.firebase.database.core.utilities.encoding.CustomClassMapper.convertBean(com.google.firebase:firebase-database@@16.0.4:420)
          at com.google.firebase.database.core.utilities.encoding.CustomClassMapper.deserializeToClass(com.google.firebase:firebase-database@@16.0.4:214)
          at com.google.firebase.database.core.utilities.encoding.CustomClassMapper.convertToCustomClass(com.google.firebase:firebase-database@@16.0.4:79)
          at com.google.firebase.database.DataSnapshot.getValue(com.google.firebase:firebase-database@@16.0.4:212)
          at com.example.clone.LoginActivity$3$1.onDataChange(LoginActivity.java:102)
          at com.google.firebase.database.Query$1.onDataChange(com.google.firebase:firebase-database@@16.0.4:183)
          at com.google.firebase.database.core.ValueEventRegistration.fireEvent(com.google.firebase:firebase-database@@16.0.4:75)
          at com.google.firebase.database.core.view.DataEvent.fire(com.google.firebase:firebase-database@@16.0.4:63)
          at com.google.firebase.database.core.view.EventRaiser$1.run(com.google.firebase:firebase-database@@16.0.4:55)
          at android.os.Handler.handleCallback(Handler.java:873)
          at android.os.Handler.dispatchMessage(Handler.java:99)
          at android.os.Looper.loop(Looper.java:201)
          at android.app.ActivityThread.main(ActivityThread.java:6820)
          at java.lang.reflect.Method.invoke(Native Method)
          at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:922)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/WpDGL.png" rel="nofollow noreferrer">the screenshot given below is the screenshot of the firebase console of the app</a></p>