cinndis
cinndis

Reputation: 1

How to show post based on user that's logged in?

So I'm making an android app and want to show my Post based on the user that's logged in.

This is my user's database structure

This is my post's database structure

Does anyone know how to show Post that have the same String (in this case the string from the child 'fakultas') as the String in User (the child 'admin')? Thank you.

Upvotes: 0

Views: 25

Answers (1)

Prakhar Sharma
Prakhar Sharma

Reputation: 161

Something like this perhaps

postsRef.orderByChild("fakultas").equalTo("Fak. tecknik")

Sample code :

  @Override
  public void onChildAdded(DataSnapshot dataSnapshot, String prevChildKey) {
    System.out.println(dataSnapshot.getKey());
  }

  // ...
});```

Upvotes: 1

Related Questions