Firebase路径无效:testuser@gnail.com。 Firebase路径不得包含'','#',' $',' ['或者' ]'

时间:2017-06-13 00:22:18

标签: android firebase firebase-realtime-database

我正在制作一个注册页面,我想检查输入的特定电子邮件或输入的手机是否已经存在。我认为不接受_emailText作为字符串,但接受如何获取电子邮件和密码。 这是以下代码:

public boolean userExist(){
    //private Firebase mRef = new Firebase("https://abcdefgh.firebaseio.com/users/");  
    mRef.child(_emailText.getText().toString()).addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            if(dataSnapshot.exists()){
                Toast.makeText(getBaseContext(), "Email already exist. Please choose a different one", Toast.LENGTH_SHORT).show();
                _emailText.setError("Email already exist. Please choose a different one");
                valid = false;
            }
            else{
                email = _emailText.getText().toString();
            }
        }

        @Override
        public void onCancelled(FirebaseError firebaseError) {

        }
    });

    mRef.child(_mobileText.getText().toString()).addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            if(dataSnapshot.exists()){
                _mobileText.setError("Mobile Number already exist");
                valid = false;

            }
            else{
                mobile = _mobileText.getText().toString();

            }
        }

        @Override
        public void onCancelled(FirebaseError firebaseError) {

        }
    });


    return valid;
}

数据库结构如下:

1 个答案:

答案 0 :(得分:1)

您的子密钥是5Ri...,而不是电子邮件

你正在寻找这个

mRef = new Firebase("https://abcdefgh.firebaseio.com/");
mRef.child("users")
    .orderByChild("email")
    .equalTo("testuser@gnail.com").addListener...( ) {

};