How to get an authenticated user to see another user’s posts tbm authenticated?

Asked

Viewed 59 times

1

When I take the node reference in the database and use Child to return the current user data, it works cool, but I don’t know how to implement the data return(posts) of other authenticated users in the app.

postagemRef = database.getReference("postagens").child(mAuth.getCurrentUser().getUid());

Note: I am using dataBinding to display the data on the main screen, which would be a kind of feed.

1 answer

1


Do so:

DatabaseReference ref = FirebaseDatabase.getInstance().getReference().child("postagens")

and then in addListenerForSingleValueEvent, you will have to convert within a loop taking all references to your type and treat. Just give a thought, because the posts you will have to add a new Systener because the way you implemented the bank, you will have to pick the users with posts, and then the posts. It is better in the posts, key the key to be the post ID, and have the user within that key.

Correct me if I’m wrong, but your key is

postagens
 - usuario(key)
  - Postagem em Sí

should be

postagens
 - Postagem (id)
  - Dados da postagem, com uma key sendo o usuario.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.