Reputation: 23
Here is my code:
mFirebaseDatabae = FirebaseDatabase.getInstance();
mMessageReference = FirebaseDatabase.getInstance().getReference().child("memos");
serchButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mMessageReference.orderByChild("title").equalTo("z").addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Toast.makeText(SerchActivity.this, "print", Toast.LENGTH_LONG).show();
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
});
Here is my Firebase tree:
Isn't it possible for the title to be printed only when the title is z?
Upvotes: 0
Views: 173
Reputation: 1971
Fatch like this way...
for (DataSnapshot messageSnapshot : dataSnapshot.getChildren()) {
String title= (String) messageSnapshot.child("title").getValue();
}
Upvotes: 2