View Postime 0,1 Error While Retrieving Data From Firebase
Here I am trying to display the data for the current logged in user. If there is any other method to retrieve data pls share. This is my database : This is the code I have used f
Solution 1:
You are storing the values under a random id:
reference.push().setValue(ud);
This code generates a random id and under it you will have the attributes of class UserDetails
, you need to change it to the following:
mfirebase.createUserWithEmailAndPassword(email,pwd).addOnCompleteListener(Signup.this, new OnCompleteListener<com.google.firebase.auth.AuthResult>() {
@Override
public void onComplete(@NonNull Task<com.google.firebase.auth.AuthResult> task) {
if(!task.isSuccessful()){
Toast.makeText(Signup.this,"Signup Unsuccessful",Toast.LENGTH_SHORT).show();
}
else
{
Toast.makeText(Signup.this,"Account Created Successfully and You're now logged in",Toast.LENGTH_SHORT).show();
reference.child(task.getResult().getUser().getUid()).setValue(ud); //add this linefinish();
startActivity(new Intent(Signup.this,Login.class));
//Toast.makeText(Signup.this,"Account Created Successfully",Toast.LENGTH_SHORT).show();
}
After you change it to the above, then when you retrieve you can use this:
reference= FirebaseDatabase.getInstance().getReference().child("User").child(FirebaseAuth.getInstance().getCurrentUser().getUid());
Post a Comment for "View Postime 0,1 Error While Retrieving Data From Firebase"