Error Firebase Database paths must not contain

0

Good evening community

I need you to help me with the following, apparently the firebase releases an error with the commas and other points

THIS IS MY CODE:

                 public void onDataChange(DataSnapshot dataSnapshot) {
                    if(dataSnapshot.child(user.getUsuario()).exists()){
                        Toast.makeText(MainActivity.this, "El Usuario ya existe!", Toast.LENGTH_SHORT).show();
                    }
                        else
                    {
                        if(dataSnapshot.child(user.getEmail()).exists()){
                            Toast.makeText(MainActivity.this, "El Correo ya existe!", Toast.LENGTH_SHORT).show();
                        }
                        else {
                            usuarios.child(user.getUsuario()).setValue(user);
                            Toast.makeText(MainActivity.this,"Registrado!", Toast.LENGTH_SHORT).show();
                        }

                    }

THIS IS THE LOG:

  

com.google.firebase.database.DatabaseException: Invalid Firebase Database path: [email protected]. Firebase Database paths must not contain '.', '#', '$', '[', Or ']'                                                        at com.google.android.gms.internal.zzbtf.zzjl (Unknown Source)                                                        at com.google.firebase.database.DatabaseReference.child (Unknown Source)                                                        at com.google.firebase.database.DataSnapshot.child (Unknown Source)                                                        at com.example.gianp.demo.MainActivity $ 2 $ 1.onDataChange (MainActivity.java:72)                                                        at com.google.firebase.database.Query $ 1.onDataChange (Unknown Source)                                                        at com.google.android.gms.internal.zzbpx.zza (Unknown Source)                                                        at com.google.android.gms.internal.zzbqx.zzZS (Unknown Source)                                                        at com.google.android.gms.internal.zzbra $ 1.run (Unknown Source)                                                        at android.os.Handler.handleCallback (Handler.java:751)

    
asked by Gian Paul Ramírez Pacheco 16.10.2017 в 20:50
source

1 answer

0

The problem is:

  

Invalid Firebase path: .com. Firebase paths must not contain '.', '#', '$', '[', Or ']'

The nomenclature of the path where the database is located can not have the following characters: '.', '#', '$', '[', o ']'
You are assigning an email as the path where the database is located, which is incorrect:

The reference is incorrect, you should not use the aforementioned characters:

DatabaseReference reference = database.getReference("https://<......>.firebaseio.com/");

You can use this name, by removing the "." and "@":

DatabaseReference reference = database.getReference("https://gianprphotmailcom.firebaseio.com/");

or s implement get the reference in this way, it is the most appropriate since it takes the url you defined when you configured your project :

DatabaseReference reference = database.getReference();
    
answered by 16.10.2017 в 20:57