I was creating a signup page in android studio and connected it to firebase but the problem is it doesn't show me the password in Realtime database when I sign up(although the Email gets stored in authentication) this is my signup code
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
import com.example.deliveryapp.Models.Users;
import com.example.deliveryapp.databinding.ActivitySignUpBinding;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.database.FirebaseDatabase;
public class SignUp extends AppCompatActivity {
ActivitySignUpBinding binding;
private FirebaseAuth mAuth;
FirebaseDatabase database;
ProgressDialog progressdialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding=ActivitySignUpBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
mAuth = FirebaseAuth.getInstance();
database=FirebaseDatabase.getInstance();
progressdialog=new ProgressDialog(SignUp.this);
progressdialog.setTitle("Creating Account");
progressdialog.setMessage("pls wait while we create your account");
binding.SignUp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
progressdialog.show();
mAuth.createUserWithEmailAndPassword(binding.Email.getText().toString()
,binding.Password.getText().toString()).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
progressdialog.dismiss();
if (task.isSuccessful()) {
Users user=new Users(binding.Username.getText().toString(),binding.Email.getText().toString(),binding.Password.getText().toString());
Toast.makeText(SignUp.this, "Account created", Toast.LENGTH_SHORT).show();
String id=task.getResult().getUser().getUid();
database.getReference().child("Users").child(id).setValue(user);
}
else {
Toast.makeText(SignUp.this, task.getException().getMessage(), Toast.LENGTH_SHORT).show();
}
}
});
}
});
}
}
and the users class is this
public Users(String username, String mail, String password) {
this.Username = username;
this.mail = mail;
this.Password = password;
}
and these are my dependencies
dependencies {
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'com.google.firebase:firebase-auth:21.0.1'
implementation 'com.google.firebase:firebase-database:20.0.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation platform('com.google.firebase:firebase-bom:28.1.0')
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.android.gms:play-services-location:18.0.0'
}
My app runs normally without any error being thrown in logcat