【问题标题】:Firebase database not getting all key/values from android deviceFirebase 数据库未从 android 设备获取所有键/值
【发布时间】:2017-12-11 22:37:01
【问题描述】:

我正在使用 firebase 数据库进行实时聊天,但它只是有时会跳过内部的键/值以添加到数据库中

这就是我将数据添加到 Firebase 数据库的方式

Map<String, Object> map = new HashMap<>();
                            map.put("Message_From",  userSession.getUserFname() + " " +  userSession.getUserLname());
                            map.put("Message_To", UserName_Intent);
                            map.put("Message", download_URI.toString());
                            map.put("Time", time);
                            map.put("Type","Video");
                            map.put("token_From",Sender_FCMToken);
                            map.put("token_To",FirebaseToken_Intent);
                            map.put("UUID", Random_UUID);

                            String Temp_Key =  databaseReference.push().getKey();
                            Map<String, Object> RoomKey = new HashMap<>();
                            databaseReference.updateChildren(RoomKey);
                            DatabaseReference message_Root =  databaseReference.child(Temp_Key);
                            message_Root.updateChildren(map);

【问题讨论】:

    标签: android firebase firebase-realtime-database hashmap


    【解决方案1】:

    我会检查您的 FirebaseToken_Intent。如果该变量中不存在任何内容或该变量为空字符串,Firebase 将不会存储它。

    【讨论】:

    • 如果它为null,那么它应该将null添加到firebase表中,然后什么都不添加。但是key应该存在于firebase服务器上,值为null
    • @androidXP 这不是它的工作原理。实时数据库中不存在空值。
    • @DougStevenson 如果值为 null 那么 firebase 不会存储任何值?如果为null,那么它也不会添加密钥?
    • 不能有没有值的键。如果您尝试将某个键的值设置为 null,则该键将消失。
    猜你喜欢
    • 1970-01-01
    • 2017-04-03
    • 2017-11-09
    • 1970-01-01
    • 1970-01-01
    • 2017-10-25
    • 2017-08-21
    • 2020-09-13
    • 1970-01-01
    相关资源
    最近更新 更多