我做了一些编码,将播放器的信息存储到Firebase中。下面是我的Firebase数据结构,其中包含一些信息,例如playerName,playerClub。
我的问题是,我需要做什么,以便我能够检索与所需条件相匹配的球员的信息,就我而言,我想检索所有将显示所有信息的守门员球员是守门员的球员的信息,包括他的名字,俱乐部。
@Override
protected void onStart()
{
super.onStart();
//attaching value event listener
databasePlayers.addValueEventListener(new ValueEventListener()
{
@Override
public void onDataChange(DataSnapshot dataSnapshot)
{
//clearing the previous player list
players.clear();
//iterating through all the nodes
for (DataSnapshot postSnapshot : dataSnapshot.getChildren())
{
//getting player
Player player = postSnapshot.getValue(Player.class);
if(player.getPlayerPosition().equals("Defender"))
{
//adding player to the list
players.add(player);
}
}
//creating adapter
GKAdminReference playerAdapter = new GKAdminReference(DFSearchList.this, players);
//attaching adapter to the listview
LVGKSList.setAdapter(playerAdapter);
}
@Override
public void onCancelled(DatabaseError databaseError)
{
}
});
}