How to make an authenticated user see the posts of another authenticated user?

1

When I get the reference from the node in the database and I use the child to return the current user's data, it works cool, but I do not know how to implement the feedback of other authenticated users in the app.

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

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

    
asked by anonymous 23.07.2017 / 03:47

1 answer

1

Do this:

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

and then in the addListenerForSingleValueEvent, you will have to convert within a loop picking up all the references for your type and handle. Only from one thought, because the posts you will have to add a new listener because the way you implemented the bank, you will have to get the users with posts, and then the posts. It is best for the posts, the key of the key to be the post ID, and to 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.
    
27.07.2017 / 15:39