Why aren’t users registering to my Realtime Firebase database?

I have been following a tutorial to create an app like Tinder for my project and I am learning databasing. I have set up the code as the tutorial said within the version of Android Studio I have, yet when I register users, they don’t appear in the database despite the profiles passing authentication. I have set the rules to true and it still hasn’t solved my problem. The only thing I can possibly think of is that my database is set to Belgium West Europe over the USA as all tutorials for Firebase show USA as the database location. If anyone has any suggestions please drop them in, thank you.

Ps: Here is the tutorial link https://www.youtube.com/watch?v=_thTn8SDjC8&list=PLxabZQCAe5fio9dm1Vd0peIY6HLfo5MCf&index=5

public class RegistrationActivity extends AppCompatActivity {

private Button mRegister;
private EditText mEmail, mPassword, mName;

private RadioGroup mRadioGroup;

private FirebaseAuth mAuth;
private FirebaseAuth.AuthStateListener firebaseAuthStateListener;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_registration);

    mAuth = FirebaseAuth.getInstance();
    firebaseAuthStateListener = new FirebaseAuth.AuthStateListener() {
        @Override
        public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
            final FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
            if (user !=null) {
                Intent intent = new Intent(RegistrationActivity.this, MainActivity.class);
                startActivity(intent);
                finish();
                return;
            }
        }
    };

    mRegister = (Button) findViewById(R.id.register);

    mEmail = (EditText) findViewById(R.id.email);
    mPassword = (EditText) findViewById(R.id.password);
    mName = (EditText) findViewById(R.id.name);

    mRadioGroup = (RadioGroup) findViewById(R.id.radioGroup);

    mRegister.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            int selectId = mRadioGroup.getCheckedRadioButtonId();

            final RadioButton radioButton = (RadioButton) findViewById(selectId);

            if(radioButton.getText() == null){
                return;
            }
            final String email = mEmail.getText().toString();
            final String password = mPassword.getText().toString();
            final String name = mName.getText().toString();
            mAuth.createUserWithEmailAndPassword(email, password).addOnCompleteListener(RegistrationActivity.this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                   if (!task.isSuccessful()){
                       Toast.makeText(RegistrationActivity.this, "Error Signing In", Toast.LENGTH_SHORT).show();
                   }else{
                       String userId = mAuth.getCurrentUser().getUid();
                       DatabaseReference currentUserDb = FirebaseDatabase.getInstance().getReference().child(radioButton.getText().toString()).child(userId).child("name");
                       currentUserDb.setValue(name);
                   }
                }
            });
        }
    });
}

@Override
protected void onStart() {
    super.onStart();
    mAuth.addAuthStateListener(firebaseAuthStateListener);
}

@Override
protected void onStop() {
    super.onStop();
    mAuth.removeAuthStateListener(firebaseAuthStateListener);
}

}

Source: Android Questions

LEAVE A COMMENT