2017-03-01 71 views
-3

這裏的圖片:如何檢索Firebase Android中的數據列表數據?

Here's the Image

如何檢索custProd內容?提前致謝。

+0

你的問題是不是clear.Post的一些詳細信息,請question.Probably你可以得到downvote – Noorul

+0

閱讀火力文檔和嘗試實施,而不是要求整個代碼請。 –

+0

你讀過這個嗎? https://firebase.google.com/docs/database/android/read-and-write – Vyacheslav

回答

1
 Firebase.setAndroidContext(this); 
     Firebase ref = new Firebase(YOUR_FIREBASE_URL); 

     ArrayList custProd= new ArrayList<>(); 

     ref.child("customerrequest/-Ke8u4..../custProd/") 
        .addListenerForSingleValueEvent(new ValueEventListener() { 
        @Override 
        public void onDataChange(DataSnapshot dataSnapshot) { 

        try { 
         if (dataSnapshot.getValue() != null) { 
         Map<String, String> value = (Map<String, String>) dataSnapshot.getValue(); 
         for (Map.Entry<String, String> entry : value.entrySet()) 
         { 
         String _key = entry.getKey(); 
         String _value = entry.getValue(); 
         // TODO add value in list 
         if (_value.length() > 0 && !custProd.contains(_value)) 
            custProd.add(_value); 
          Log.e("[email protected]::>", _key + " " + _value); 
         } 
        } 
       } catch (Exception e) { 
        e.printStackTrace(); 
      } 
     } 
     @Override 
    public void onCancelled(FirebaseError firebaseError) { 
       Log.e("[email protected]@@[email protected]@_GetAllcustProd:>", firebaseError + ""); 
     } 
}); 
+0

謝謝@Rjz,不準確,但我解決了我提到的這個問題:) –

+0

不客氣。這是獲取和存儲的方式。這是暗示......就像那樣:) –

相關問題