Retrieving data from the firbase realtime database appear as blanks in the required fields

I am creating an android app using android studio and firebase realtime database. I stored data in the firebase realtime database using UID from authentication. database structure

But when i trying to retrieve the data, the required fields on my app doesn't show any data. They appears to be blanks. Earlier i did this successfully using some other key i have generated through android studio. Then due to some issues i changed it to this authentication uid that firebase provides. Then i have changed the codes to match that.

But when i changed the part where i used to retrieve and show the data, it doesn't seems working. The data doesn't show up. Every other things works fine as i want. I cant figure out the reason for this matter. This is the the part of the code i mentioned.

private void ImportData(){

        usrRF.addValueEventListener(new ValueEventListener() {

            String fullName, userName, userName2, eMail, phoneNum, catG, paSS;
            @Override
            public void onDataChange(@NonNull DataSnapshot snapshot) {

                fullName = snapshot.child("fname").getValue(String.class);
                userName = snapshot.child("uname").getValue(String.class);
                userName2 = snapshot.child("uname").getValue(String.class);
                eMail = snapshot.child("email").getValue(String.class);
                phoneNum = snapshot.child("pnumber").getValue(String.class);
                catG = snapshot.child("spin").getValue(String.class);
                paSS = snapshot.child("pword").getValue(String.class);

                        full_name.setText(fullName);
                        user_name.setText(userName);
                        user_name2.setText(userName2);
                        email.setText(eMail);
                        phone_num.setText(phoneNum);
                        category.setText(catG);
                        pass.setText(paSS);

                        Picasso.get().load(imgRef).fit().into(profPic);

            }

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

            }
        });

In here

usrRF = FirebaseDatabase.getInstance().getReference().child("users");

When i add "child(uid)" to the code, app gets crashed. Android studio was saying that the path cannot be accessed. (for a user to open this activity from the app, he should be signed in first.)

I will be really grateful for any help.



Read more here: https://stackoverflow.com/questions/68460671/retrieving-data-from-the-firbase-realtime-database-appear-as-blanks-in-the-requi

Content Attribution

This content was originally published by Shehara_r at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: