How to make a connection request in Firebase Android

How can I effectively execute a connection request to select chatId from the " users " node, and with this chatId get the message elements from the " chats ".

JSON example: (1, 2, 134, and 155 are random user identifiers)

{
  "chats" : {
    "-KD3x3Y16YdQHWSBXR5K" : {
      "-KD3x3Y5zew00h29ZG55" : {
        "text" : "hello",
        "timestamp" : "1458224515",
        "userId" : 1
      },
      "-KD3x4B1rmbAKTVsOOYn" : {
        "text" : "test",
        "timestamp" : "1458224517",
        "userId" : 1
      }
    },
    "-KD3xLNuLU6IxB85u41S" : {
      "-KD3xLNv32FzDuqlXR1V" : {
        "text" : "bla",
        "timestamp" : "1458224588",
        "userId" : 134
      }
    }
  },
  "users" : {
    "1" : {
      "2" : {
        "chatId" : "-KD3x3Y16YdQHWSBXR5K"
      }
    },
    "134" : {
      "155" : {
        "chatId" : "-KD3xLNuLU6IxB85u41S"
      }
    }
  }
}
+4
source share

All Articles