0

I want to know how to have the reference uid of the users but I don't know how :(...

My database:

My code: https://i.stack.imgur.com/Ua1zd.jpg

FirebaseRecyclerOptions<UsersDatabaseModel> options =
                new FirebaseRecyclerOptions.Builder<UsersDatabaseModel>()
                        .setQuery(FirebaseDatabase.getInstance().getReference("Registered Users").child("userID").child("Other Account Settings"), UsersDatabaseModel.class)
                        .build();
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
BartGraphics.
  • 63
  • 1
  • 9

1 Answers1

0

If you want to get the UID of the user who is currently signed in to Firebase Authentication, you can do so with:

String uid = FirebaseAuth.getInstance().getCurrentUser().getUid();

You can then stuff that into your database reference:

FirebaseDatabase.getInstance()
  .getReference("Registered Users")
  .child(uid)
  .child("Other Account Settings")
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • I want to get the general uid reference of all users, not the current user – BartGraphics. Feb 07 '21 at 16:23
  • I'm not sure I follow, but it could be that's because there's information missing from your question. When you step through your code in a debugger, which line of the code you shared doesn't do what you expect it to do? – Frank van Puffelen Feb 07 '21 at 19:38
  • I have a RecyclerView adapter from Firebase and I want to get the name and other data of my users, but when using my code it gives me null because I don't have the uid reference. What I want to get is that, the uid of my users in general. :( – BartGraphics. Feb 07 '21 at 20:24
  • So you want to show a list of all accounts across all users? – Frank van Puffelen Feb 07 '21 at 20:47
  • You might want to edit your question (there's a link right under it), to make that more explicit. Unfortunately, you won't be able to use the adapters in FirebaseUI for that. Those are designed to show a flat list of results from a `DatabaseReference` or a `Query`. So if you want to show a list of accounts across all users with FirebaseUI, you'll have to store precisely that: a single list of accounts. See https://stackoverflow.com/questions/27207059/firebase-query-double-nested – Frank van Puffelen Feb 08 '21 at 01:34