title: java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String for (Using map to update the details from Firebase)
body: <p>Currently, I'm trying to use to update the details from my Firebase Database.However, it gives the classcastexception error. Could anyone help me to solve this problem? Thank you</p>
  
  <pre><code>E/AndroidRuntime: FATAL EXCEPTION: main
                Process: com.google.online_mobile_flexi_parking, PID: 21533
                java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String
                    at com.google.online_mobile_flexi_parking.ChangeEmailPassword$8$1.onDataChange(ChangeEmailPassword.java:243)
                    at com.google.android.gms.internal.zzakg.zza(Unknown Source)
                    at com.google.android.gms.internal.zzalg.zzcxk(Unknown Source)
                    at com.google.android.gms.internal.zzalj$1.run(Unknown Source)
                    at android.os.Handler.handleCallback(Handler.java:733)
                    at android.os.Handler.dispatchMessage(Handler.java:95)
                    at android.os.Looper.loop(Looper.java:136)
                    at android.app.ActivityThread.main(ActivityThread.java:5028)
                    at java.lang.reflect.Method.invokeNative(Native Method)
                    at java.lang.reflect.Method.invoke(Method.java:515)
                    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:788)
                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:604)
                    at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>243 line is  phoneAcc.set_IdentityCard(map.get("_IdentityCard"));</p>
  
  <p>ChangeEmailPassword.java</p>
  
  <pre><code>public class ChangeEmailPassword extends AppCompatActivity {
  
      private Button btnChangeEmail, btnChangePassword,
              changeEmail, changePassword, back, btnChangePhone, btnChangeCarPlate, changePhone,
              changeCarPlate, signOut;
  
      private EditText oldEmail, newEmail, password, newPassword, oldPhone, newPhone, confirmPassword;
      private ProgressBar progressBar;
      private FirebaseAuth.AuthStateListener authListener;
      private FirebaseAuth auth;
      DatabaseReference mDatabase;
      FirebaseUser user;
      private String txtPhone;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_change_email_password);
          Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
          toolbar.setTitle(getString(R.string.app_name));
          setSupportActionBar(toolbar);
  
          //get firebase auth instance
          auth = FirebaseAuth.getInstance();
  
          //get current user
          user = FirebaseAuth.getInstance().getCurrentUser();
          mDatabase = FirebaseDatabase.getInstance().getReference();
          authListener = new FirebaseAuth.AuthStateListener() {
              @Override
              public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
                  FirebaseUser user = firebaseAuth.getCurrentUser();
                  if (user == null) {
                      // user auth state is changed - user is null
                      // launch login activity
                      startActivity(new Intent(ChangeEmailPassword.this, TestUser.class));
                      finish();
                  }
              }
          };
  
          btnChangeEmail = (Button) findViewById(R.id.change_email_button);
          btnChangePassword = (Button) findViewById(R.id.change_password_button);
          btnChangePhone=(Button)findViewById(R.id.change_phone_button);
          changeEmail = (Button) findViewById(R.id.changeEmail);
          changePassword = (Button) findViewById(R.id.changePass);
          changePhone=(Button) findViewById(R.id.changePhone);
          //signOut = (Button) findViewById(R.id.sign_out);
          back=(Button)findViewById(R.id.btnback1);
  
          oldEmail = (EditText) findViewById(R.id.old_email);
          newEmail = (EditText) findViewById(R.id.new_email);
          password = (EditText) findViewById(R.id.password);
          newPassword = (EditText) findViewById(R.id.newPassword);
          confirmPassword=(EditText)findViewById(R.id.confirmpassword);
          oldPhone=(EditText)findViewById(R.id.old_phone);
          newPhone=(EditText)findViewById(R.id.new_phone);
  
  
          oldEmail.setVisibility(View.GONE);
          newEmail.setVisibility(View.GONE);
          password.setVisibility(View.GONE);
          newPassword.setVisibility(View.GONE);
          confirmPassword.setVisibility(View.GONE);
          changeEmail.setVisibility(View.GONE);
          changePassword.setVisibility(View.GONE);
          oldPhone.setVisibility(View.GONE);
          newPhone.setVisibility(View.GONE);
          progressBar = (ProgressBar) findViewById(R.id.progressBar);
  
          if (progressBar != null) {
              progressBar.setVisibility(View.GONE);
          }
  
          back.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  startActivity(new Intent(ChangeEmailPassword.this, TestUser.class));
                  finish();
              }
          });
  
          btnChangeEmail.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  oldEmail.setVisibility(View.GONE);
                  newEmail.setVisibility(View.VISIBLE);
                  password.setVisibility(View.GONE);
                  newPassword.setVisibility(View.GONE);
                  confirmPassword.setVisibility(View.GONE);
                  changeEmail.setVisibility(View.VISIBLE);
                  changePassword.setVisibility(View.GONE);
                  changePhone.setVisibility(View.GONE);
                  oldPhone.setVisibility(View.GONE);
                  newPhone.setVisibility(View.GONE);
              }
          });
  
          changeEmail.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  progressBar.setVisibility(View.VISIBLE);
                  if (user != null &amp;&amp; !newEmail.getText().toString().trim().equals("")) {
                      user.updateEmail(newEmail.getText().toString().trim())
                              .addOnCompleteListener(new OnCompleteListener&lt;Void&gt;() {
                                  @Override
                                  public void onComplete(@NonNull Task&lt;Void&gt; task) {
                                      if (task.isSuccessful()) {
  
                                          Toast.makeText(ChangeEmailPassword.this, "Email address is updated. Please sign in with new email id!", Toast.LENGTH_LONG).show();
                                          startActivity(new Intent(ChangeEmailPassword.this, MainActivity.class));
                                          finish();
  
                                          progressBar.setVisibility(View.GONE);
                                      } else {
                                          Toast.makeText(ChangeEmailPassword.this, "Failed to update email!", Toast.LENGTH_LONG).show();
                                          progressBar.setVisibility(View.GONE);
                                      }
                                  }
                              });
                  } else if (newEmail.getText().toString().trim().equals("")) {
                      newEmail.setError("Enter email");
                      progressBar.setVisibility(View.GONE);
                  }
              }
          });
  
          btnChangePassword.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  oldEmail.setVisibility(View.GONE);
                  newEmail.setVisibility(View.GONE);
                  password.setVisibility(View.GONE);
                  newPassword.setVisibility(View.VISIBLE);
                  confirmPassword.setVisibility(View.VISIBLE);
                  changeEmail.setVisibility(View.GONE);
                  changePassword.setVisibility(View.VISIBLE);
                  changePhone.setVisibility(View.GONE);
                  oldPhone.setVisibility(View.GONE);
                  newPhone.setVisibility(View.GONE);
              }
          });
  
          changePassword.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  progressBar.setVisibility(View.VISIBLE);
                  if (user != null &amp;&amp; !newPassword.getText().toString().trim().equals("")) {
                      if (newPassword.getText().toString().trim().length() &lt; 6) {
                          newPassword.setError("Password too short, enter minimum 6 characters");
                          progressBar.setVisibility(View.GONE);
                      } else if (!(newPassword.getText().toString().trim().equals(confirmPassword.getText().toString().trim()))) {
                          newPassword.setError("Password are not matching");
                          progressBar.setVisibility(View.GONE);
                      } else {
                          user.updatePassword(newPassword.getText().toString().trim())
                                  .addOnCompleteListener(new OnCompleteListener&lt;Void&gt;() {
                                      @Override
                                      public void onComplete(@NonNull Task&lt;Void&gt; task) {
                                          if (task.isSuccessful()) {
                                              Toast.makeText(ChangeEmailPassword.this, "Password is updated, sign in with new password!", Toast.LENGTH_SHORT).show();
                                              startActivity(new Intent(ChangeEmailPassword.this, MainActivity.class));
                                              finish();
  
                                              progressBar.setVisibility(View.GONE);
                                          } else {
                                              Toast.makeText(ChangeEmailPassword.this, "Failed to update password!", Toast.LENGTH_SHORT).show();
                                              progressBar.setVisibility(View.GONE);
                                          }
                                      }
                                  });
                      }
                  } else if (newPassword.getText().toString().trim().equals("")) {
                      newPassword.setError("Enter password");
                      progressBar.setVisibility(View.GONE);
                  }
              }
          });
  
          btnChangePhone.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  oldEmail.setVisibility(View.GONE);
                  newEmail.setVisibility(View.GONE);
                  password.setVisibility(View.GONE);
                  newPassword.setVisibility(View.GONE);
                  confirmPassword.setVisibility(View.GONE);
                  changeEmail.setVisibility(View.GONE);
                  changePassword.setVisibility(View.GONE);
                  changePhone.setVisibility(View.VISIBLE);
                  oldPhone.setVisibility(View.GONE);
                  newPhone.setVisibility(View.VISIBLE);
              }
          });
  
  
          changePhone.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  progressBar.setVisibility(View.VISIBLE);
                  txtPhone = newPhone.getText().toString().trim();
                  if (!txtPhone.equals("")) {
                      mDatabase.child(user.getUid()).addValueEventListener(new ValueEventListener() {
                          @Override
                          public void onDataChange(DataSnapshot dataSnapshot) {
                              Account phoneAcc=new Account();
                              Map&lt;String,String&gt; map=(Map)dataSnapshot.getValue();
                              phoneAcc.set_FullName(map.get("_FullName"));
                              phoneAcc.set_CarPlate1(map.get("_CarPlate1"));
  
                              phoneAcc.set_IdentityCard(map.get("_IdentityCard"));
  
                              phoneAcc.set_Phone(txtPhone);
                              mDatabase.child(user.getUid()).setValue(phoneAcc);
                              Toast.makeText(ChangeEmailPassword.this, "Phone is updated, sign in with new password!", Toast.LENGTH_SHORT).show();
                              startActivity(new Intent(ChangeEmailPassword.this, MainActivity.class));
                              finish();
                              progressBar.setVisibility(View.GONE);
                          }
  
                          @Override
                          public void onCancelled(DatabaseError databaseError) {
  
                          }
                      });
  
                      } else if (txtPhone.equals("")) {
                      newPhone.setError("Enter phone number");
                      progressBar.setVisibility(View.GONE);
                  }
              }
          });
      }
  }
  </code></pre>
  
  <p>Account.java    </p>
  
  <pre><code>  public class Account {
          private String _Phone;
          private String _IdentityCard;
          private String _FullName;
          private String _CarPlate1;
          private String _CarPlate2;
          private String _CarPlate3;
  
      public Account(){}
  
      public Account(String fullname, String phone, String carplate1, String identitycard)
      {
          this._Phone=phone;
          this._CarPlate1=carplate1;
          this._FullName=fullname;
          this._IdentityCard=identitycard;
      }
  
      public Account(String carplate1,String carplate2,String carplate3)
      {
          this._CarPlate1=carplate1;
          this._CarPlate2=carplate2;
          this._CarPlate3=carplate3;
      }
      public void set_Phone(String _Phone) {
          this._Phone = _Phone;
      }
  
      public String get_Phone() {
          return _Phone;
      }
  
      public String get_IdentityCard() {
          return _IdentityCard;
      }
  
      public void set_IdentityCard(String _IdentityCard){this._IdentityCard=_IdentityCard;}
  
      public String get_FullName() {
          return _FullName;
      }
  
      public void set_FullName(String _FullName){ this._FullName=_FullName;}
  
      public void set_CarPlate1(String _CarPlate1) {
          this._CarPlate1 = _CarPlate1;
      }
  
      public String get_CarPlate1() {
          return _CarPlate1;
      }
  
      public void set_CarPlate2(String _CarPlate2) {
          this._CarPlate2 = _CarPlate2;
      }
  
      public String get_CarPlate2() {
          return _CarPlate2;
      }
  
      public void set_CarPlate3(String _CarPlate3) {
          this._CarPlate3 = _CarPlate3;
      }
  
      public String get_CarPlate3() {
          return _CarPlate3;
      }
  }
  </code></pre>