0

Firebase database structure

Please how i can get data from firebase with IMEI of the phone.

enter image description here

How i can get listcarte by the phone TPEID!!

1 Answers1

0

If the value you're looking for is always in 0/TPEID, then you can use a query to find the nodes that contains that value with:

DatabaseReference ref = FirebaseDatabase.getInstance().getReference(...);
Query query = ref.orderByChild("0/TPEID").equalTo("869688030960688");
query.addListenerForSingleValueEvent(new ValueEventListener() {
  @Override
  public void onDataChange(DataSnapshot dataSnapshot) {
    for (DataSnapshot tpeSnapshot: dataSnapshot.getChildren()) {
        System.out.println(tpeSnapshot.getKey()); // Tpe0
        System.out.println(tpeSnapshot.child("0/TPEID").getValue(String.class)); // 869688030960688
    }
  }

  @Override
  public void onCancelled(DatabaseError databaseError) {
    throw databaseError.toException();
  }
}

If the value is not at a fixed path under each child, you won't be able to search for it with a Firebase query. In that case, see Firebase Query Double Nested, firebase get url by nested child id for tree like, Firebase query if child of child contains a value

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807