Firebase “Failed to convert a value of type java.util.HashMap to int”

后端 未结 3 1661
半阙折子戏
半阙折子戏 2021-01-21 17:05

At this line of my code in my OnDataChange() method in the ValueEvenListener:

int latest = dataSnapshot.getValue(Integer.class);
         


        
3条回答
  •  广开言路
    2021-01-21 18:11

    It turns out I had to child dataSnapshot to my destination again. E.g:

    int latest = dataSnapshot.child("Campaigns").child(key).child("count").getValue(Integer.class);
    

    By default dataSnapshot is actually my whole database.

提交回复
热议问题