如何获取属性项?
这是我尝试阅读的方式
for (DataSnapshot snap : dataSnapshot.getChildren()) {
User user = snap.getValue(User.class);
mPropertyList = snap.getValue(User.class).getProperty();
//if not current user, as we do not want to show ourselves then chat with ourselves lol
try {
mAllUserList.add(user);
if (mAuth.getCurrentUser().getEmail().equals(user.getEmail()))
if (user.getUser_type().equals("landlord")) {
user_rule = "landlord";
landUser = user;
}
} catch (Exception e) {
e.printStackTrace();
}
}
答案 0 :(得分:1)
要获取“属性”项,请尝试以下操作:
FirebaseUser user=FirebaseAuth.getInstance().getCurrentUser();
String userid=user.getUid();
DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference();
DatabaseReference usersRef = rootRef.child("Users").child(userid).child("properties");
usersRef.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for(DataSnapshot datas: dataSnapshot.getChildren()){
String desc=datas.child("description").getValue().toString();
String type=datas.child("type").getValue().toString();
//get other items
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
快照在properties
迭代后,您将能够获得那里的项目