【发布时间】:2018-01-29 22:53:33
【问题描述】:
我遇到了问题,我尝试了所有方法,但找不到解决方案。我有一个这样的firebase数据库。聊天:
-聊天
--0
---title=""
---lastmsg=""
---timestamp=""
--1
---title=""
---lastmsg=""
---timestamp=""
然后:
-成员
--0
---uid0="真"
---uid1="真"
--1
---uid2="真"
---uid3="true"
现在,我有这个 java 代码来处理列表。
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference myRef = database.getReference("chats");
myRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
// This method is called once with the initial value and again
// whenever data at this location is updated.
Iterable<DataSnapshot> children = dataSnapshot.getChildren();
for (DataSnapshot child : children) {
String titolo = (String) child.child("titolo").getValue();
String ultimomsg = (String) child.child("ultimomsg").getValue();
Long timestamp = (Long) child.child("timestamp").getValue();
Log.w(TAG, "Title is: "+ titolo);
CHATITEMS.add(new DummyItem(child.getKey(), titolo, ultimomsg, timestamp));
}
RecyclerView recyclerView = (RecyclerView) view;
recyclerView.setAdapter(new MyPersonRecyclerViewAdapter(CHATITEMS, mListener));
}
现在,我希望用户只有在用户 ID 位于节点成员/聊天编号/用户 ID 上时才能读取聊天节点。我尝试了几种方法来制定规则,但没有成功。谁能指出我正确的方向?谢谢
【问题讨论】:
标签: java android firebase firebase-realtime-database firebase-security