How to store data in realtime database in firebase during user registration?
<p>I'm making socialmedia-like app that has user profile. I want to save their profile data upon their registration using their uid. Although the registration is successful, profile is not saving in the firebase database. I've also checked the rules, and read and write is set for authenticated users.</p>

<p>Here's my code:</p>

<pre><code>public class RegisterActivity extends AppCompatActivity implements View.OnClickListener {

private Button btn_reg;
private EditText etName, etEmail, etPassword, etCPassword, etMobile, etSchoolCompany, etLocation;
private ProgressDialog progressDialog;
private FirebaseAuth firebaseAuth;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_register);

    Firebase.setAndroidContext(this);

    firebaseAuth = FirebaseAuth.getInstance();

    progressDialog = new ProgressDialog(this);

    btn_reg = (Button)findViewById(R.id.btnRegister);
    etName = (EditText)findViewById(R.id.etName);
    etEmail = (EditText)findViewById(R.id.etEmail);
    etPassword = (EditText)findViewById(R.id.etPassword);
    etCPassword = (EditText)findViewById(R.id.etCPassword);
    etMobile = (EditText)findViewById(R.id.etMobile);
    etSchoolCompany = (EditText)findViewById(R.id.etSchoolCompany);
    etLocation = (EditText)findViewById(R.id.etLocation);

    btn_reg.setOnClickListener(this);
}

@Override
public void onClick (View view){
    if(view == btn_reg){
        registerUser();
    }
}

private void registerUser(){
    String name = etName.getText().toString();
    String mobile = etMobile.getText().toString();
    String SchoolCompany = etSchoolCompany.getText().toString();
    String location = etLocation.getText().toString();
    final String email = etEmail.getText().toString().trim();
    final String password = etPassword.getText().toString().trim();
    String cpassword = etCPassword.getText().toString().trim();

    progressDialog.setMessage("Registering..");
    progressDialog.show();

    //REGISTERING USER
    firebaseAuth.createUserWithEmailAndPassword(email, password)
            .addOnCompleteListener(this, new OnCompleteListener&lt;AuthResult&gt;() {
                @Override
                public void onComplete(@NonNull Task&lt;AuthResult&gt; task) {
                    if(task.isSuccessful()){

                        //THIS IS FOR STORING AUTHENTICATED USER'S DATA
                        final Firebase ref = new Firebase("https://myfirebase.firebaseio.com");
                        ref.authWithPassword(email, password, new Firebase.AuthResultHandler(){
                            @Override
                            public void onAuthenticated(AuthData authData){
                                // Authentication just completed successfully :)
                                Map&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
                                map.put("provider", authData.getProvider());
                                if(authData.getProviderData().containsKey("displayName")) {
                                    map.put("displayName", authData.getProviderData().get("displayName").toString());
                                }
                                ref.child("users").child(authData.getUid()).setValue(map);
                            }
                            @Override
                            public void onAuthenticationError(FirebaseError error) {
                //ERRORS TODO
                            }
                        });
                        progressDialog.hide();
                        Toast.makeText(RegisterActivity.this, "Registered Successfully", Toast.LENGTH_SHORT).show();
                    }else{
                        Toast.makeText(RegisterActivity.this, "Registration failed, please try again", Toast.LENGTH_SHORT).show();
                    }
                }

            });
}


}
</code></pre>