将一个电子邮件的数据保存到另一电子邮件时出错

时间:2018-07-19 15:55:38

标签: java android firebase firebase-realtime-database

enter image description here

下面的代码运行正常,但是登录时,一个Gmail ID数据将保存到另一个Gmail ID中。也就是说,通过一个Gmail登录时,我会获得之前已注册的另一个Gmail ID的数据,并且我只能登录一个在初始状态下已注册的Gmail ID。当登录初始v时,数据库中将显示最后注册的数据库。

       fAuth = FirebaseAuth.getInstance();
    String uid = fAuth.getUid();

    fUserDatabase = 
 FirebaseDatabase.getInstance().getReference("user").child(uid);

    Register_button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String uEmail = inEmail.getText().toString().trim();
            String uName = inName.getText().toString().trim();
            String uPassword = inPassword.getText().toString().trim();
            String uRePassword = inRePassword.getText().toString().trim();
            String uContact = inContact.getText().toString().trim();
            String uAddress = inAddress.getText().toString().trim();
            String uSkill = inSkill.getText().toString().trim();
            String uExp = inExp.getText().toString().trim();
            String uQual = inQual.getText().toString().trim();
            register_user(uName 
,uEmail,uPassword,uRePassword,uAddress,uContact,uSkill,uQual,uExp);
          }
    });
}

private void register_user(final String name, final String email, String 
password, String rePassword, final String address, final String 
contact, final String Skill, final String Qualification, final String Exp) 
 {

progressDialog = new ProgressDialog(this);
progressDialog.setMessage("Processing your data, Please wait . . .");
progressDialog.show();



fAuth.createUserWithEmailAndPassword(email, 
password).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
    @Override
    public void onComplete(@NonNull Task<AuthResult> task) {
        if(task.isSuccessful()){

                                String id = fAuth.getUid();
                                user_details user = new 
user_details(id,name,address,contact,email,Qualification,Exp,Skill);
                                fUserDatabase.setValue(user);

                                Toast.makeText(JobSignup.this, "User has 
been created!", Toast.LENGTH_SHORT).show();
                                Intent i = new Intent(JobSignup.this, 
Uploadimage.class);
                                startActivity(i);
                                finish();
                            }else{
                                progressDialog.dismiss();
                                Toast.makeText(JobSignup.this, "Error: 
 "+task.getException().getMessage(), Toast.LENGTH_SHORT).show();
                            }


    }
});

0 个答案:

没有答案