Android Retriving the data from firebase using Phone Number

  android, java

I am trying to fetch the data of current user with PhoneNumber from firebase database but i am not able to fetch the data
My Application is PhoneAuthtication and i have qiven the number as a child and reference path is User What should i do to fetch the data

reference = FirebaseDatabase.getInstance().getReference("Users");
reference.child(user.getPhoneNumber()).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {
String A = String.valueOf(snapshot.child("fullName").getValue());
String B = String.valueOf(snapshot.child("phone1").getValue());
String C = String.valueOf(snapshot.child("phone2").getValue());
String D = String.valueOf(snapshot.child("message").getValue());

            Name.setText(A);
            Phone1.setText(B);
            Phone2.setText(C);
            Message.setText(D);

        }

        @Override
        public void onCancelled(@NonNull DatabaseError error) {

        }
    });

   Show.setOnClickListener(new View.OnClickListener() {
       @Override
       public void onClick(View v) {
           Intent intent = new Intent(ProfileActivity.this,HomeActivity.class);
           startActivity(intent);
           finish();
       }
   });

Source: Android Questions

LEAVE A COMMENT