我正在使用以下代码在Firebase上保存数据。但是数据没有保存在Firebase中,我该如何解决?

时间:2019-06-26 10:02:25

标签: android firebase

[[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]

1 个答案:

答案 0 :(得分:0)

尝试像这样添加故障侦听器并输出错误(如果存在):

mAuth.createUserWithEmailAndPassword(em,pass).addOnCompleteListener(task -> {
            //Successful
            if(task.isSuccessful()){
                String userid=mAuth.getCurrentUser().getUid();
                DatabaseReference curentuserDB=mDatabaseReference.child(userid);
                        curentuserDB.child("UserName").setValue(username);
                        curentuserDB.child("phone").setValue(phoneNum);
                        curentuserDB.child("location").setValue(loc);
                        curentuserDB.child("Description").setValue(desc);

                        mProgress.dismiss();

                        Intent intent = new Intent(Register.this,Post.class);
                        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                        startActivity(intent);
            }
            //Error
            else {                
                Log.d("Error", Objects.requireNonNull(Objects.requireNonNull(task.getException()).getLocalizedMessage()));
            }

        }).addOnFailureListener(e -> {
                Log.d("Error", Objects.requireNonNull(e.getLocalizedMessage()));
        });