簡體   English   中英

如何在Firebase中檢索唯一鍵的所有子節點

[英]How can i retrieve all child nodes of unique key in Firebase

我正在創建一個使用Firebase和Geofire的應用程序。 我能夠在FireBase中存儲值。

在Geoquery中,我得到了該特定區域中的鍵。 我只想檢索該特定鍵的所有子節點。 我怎么做?

我想檢索鍵-KpzaWx6FfdT27FlEoaZ的子值

我怎么做?

請給出完整的代碼以獲取-KpzaWx6FfdT27FlEoaZ <----的所有值,只有我應該得到的

假設user_Location是Firebase根目錄的直接子級,請使用以下代碼:

DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference();
DatabaseReference userLocationRef = rootRef.child("user_Location").child("-KpzaWx6FfdT27FlEoaZ").child("l");
ValueEventListener eventListener = new ValueEventListener() {
    @Override
    public void onDataChange(DataSnapshot dataSnapshot) {
        Double lat = ds.child("0").getValue(Double.class);
        Double long = ds.child("0").getValue(Double.class);
        Log.d("TAG", lat + " / " + long);
    }

    @Override
    public void onCancelled(DatabaseError databaseError) {}
};
userLocationRef.addListenerForSingleValueEvent(eventListener);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM