2017-08-17 92 views
-3

enter image description here如何存取權限的數據庫火力地堡

我想NomDirection但它不爲我工作的屬性,任何幫助plzzz?!

Fdatabase = FirebaseDatabase.getInstance().getReference().child("Fondation").child("Directions"); 
Fdatabase.orderByChild("NomDirection").addValueEventListener(new com.google.firebase.database.ValueEventListener() { 
    @Override 
    public void onDataChange(com.google.firebase.database.DataSnapshot dataSnapshot) { 
     //final List<String> etab = new ArrayList<String>(); 
     for (DataSnapshot child : dataSnapshot.getChildren()) { 
      namedirection = (String) child.child("NomDirection").getValue(); 
      // etab.add(namedirection); 
      Toast.makeText(testFondation.this,namedirection,Toast.LENGTH_SHORT).show(); 

     } 

    } 

回答

1

您必須使用.getReference().child("Fondation").child("-KrjG...").child("Directions")

Better lookin .getReference("Fondation/-KrjG.../Directions)

因此,您需要將您的密鑰(以您的案例中的「KrjG ...」開頭)插入查詢中。

+0

ohh對不起,對於這裏的錯誤,我已經添加了這個孩子,但它沒有工作! :( –

+0

@IkramLaaroussi嗨你有沒有檢查這個鏈接https://stackoverflow.com/questions/41591045/how-to-get-nested-child-from-firebase-database-using-android?它會爲你工作。 – Piyush

+0

@IkramLaaroussi你可以檢查鏈接如何檢索數據與關鍵和值 – Piyush