Android Firebase 2.4 IllegalStateException using new ref.updateChildren()

后端 未结 2 1324
清酒与你
清酒与你 2020-12-10 08:43

When using Firebase 2.4 ref.updateChildren() with HashMap, other than HashMap (e.g. HashMap)

2条回答
  •  自闭症患者
    2020-12-10 09:12

    As in the code snippet from the Official Firebase Blog to avoid this issue one has to re-write custom structure like this:

    Map newPost = new HashMap();
    newPost.put("title", "New Post");
    newPost.put("content", "Here is my new post!");
    

    And then put it instead of custom data model:

    Map updatedUserData = new HashMap();
    updatedUserData.put("users/posts/" + newPostKey, true);
    updatedUserData.put("posts/" + newPostKey, newPost);
    

    Using custom data model instead of newPost causes IllegalStateException.

提交回复
热议问题