且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从Firebase检索所有用户ID的数据

更新时间:2023-01-30 09:16:10

database.child("usuario").addValueEventListener(new ValueEventListener() {
    public void onDataChange(DataSnapshot dataSnapshot) {
         for (DataSnapshot snapshot: dataSnapshot.getChildren()) {
             for (DataSnapshot messageSnapshot: snapshot.child("mensagem").getChildren()) {
                 listView.add(messageSnapshot.child("textoMensagem").getValue().toString());
             }
         }
    }

    ...

如您所见,我添加了一个ValueEventListener来检索"usuario"的所有子节点,然后循环浏览其子节点以获取您的消息.

As you can see I add a ValueEventListener to retrieve all children nodes of "usuario" and then loop through its children to get to your messages.

提示:考虑(至少)以英语发布您的代码/数据库结构等,这可以使您阅读问题变得更加容易.