![](/img/trans.png)
[英]How can I get the last updated data in firebase to android studio and show it in textview while the key is generated from other source
[英]Android & Firebase : How can i get data from frebase by key
如果您要查找的值始終在0/TPEID
中,那么您可以使用查詢來查找包含該值的節點:
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();
}
}
如果該值不在每個子項下的固定路徑中,您將無法使用 Firebase 查詢來搜索它。 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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.