FireBase Query. DataSnapshot

后端 未结 2 975
青春惊慌失措
青春惊慌失措 2021-01-25 09:10

I need help on getting the \"message\" Object from this DataSnapshot result

DataSnapshot { key = user-4, value = {-JvFuwKX7r7o0ThXc0x8={sender=unit_owner, messag         


        
2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-25 09:56

    The value will be returned as an Object, as you've stated, but you can actually cast it to Map since you know it should be a map.

    So, do something like this:

    Map val = (Map) dataSnapshot.getValue();
    String message = (String) val.get("message");
    String sender = (String) val.get("sender");
    

提交回复
热议问题