Retrieve data to text view from fire base without parent key

  • Replies:2
  • OpenNot stickiedAnswered
  • Forum posts: 2

May 13, 2018 4:16:08 AM via Website

image
here i want to search details using child without use parent key. according to this database,i want to get price and category using Name.without using parent key ("kjhsfkgkrlhg"),("get price,category where Name="super Creamcracker")

Reply
Best answer
  • Forum posts: 2

May 18, 2018 3:12:44 PM via Website

i found solution,this is that code
String pris="super Creamcracker";
DatabaseReference ref=FirebaseDatabase.getInstance().getReference().child("Items");
ref.orderByChild("Name").equalTo(pris).addValueEventListener(new ValueEventListener(){
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for(DataSnapshot datas: dataSnapshot.getChildren()){
String keys=datas.child("Price").getValue().toString();
pric.setText(keys);
}

}

@Override
public void onCancelled(DatabaseError databaseError) {

}

});
Helpful?
Reply
  • Forum posts: 12

May 18, 2018 2:56:42 PM via Website

I don't think so it is possible. Will let you know if find any solution.

Helpful?
Reply
Best answer
  • Forum posts: 2

May 18, 2018 3:12:44 PM via Website

i found solution,this is that code
String pris="super Creamcracker";
DatabaseReference ref=FirebaseDatabase.getInstance().getReference().child("Items");
ref.orderByChild("Name").equalTo(pris).addValueEventListener(new ValueEventListener(){
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for(DataSnapshot datas: dataSnapshot.getChildren()){
String keys=datas.child("Price").getValue().toString();
pric.setText(keys);
}

}

@Override
public void onCancelled(DatabaseError databaseError) {

}

});
Helpful?
Reply

Recommended articles