I need to store the list of values in following the database structure.Also how to get the list of particular post's("first") values.
"userviews" :{
"first":{
1:
"userEmail":"abc@gmail.com",
2:
"userEmail":"xyz@gmail.com"
},
"second":{
1:
"userEmail":"abc@gmail.com",
2:
"userEmail":"xyz@gmail.com"
}
}
I am developing similar to blog application.Here "userviews" is the root of the database." first" and "second" are post titles.Suppose if the user has seen the post "first", their mail has been sent to "first" list in the Firebase database.
I tried with this following solution but I didn't get proper format
String userEmail = "abc@gmail.com";
ViewedUsers viewedUsers = new ViewedUsers();
viewedUsers.setUserEmail(userEmail);
mDatabase = FirebaseDatabase.getInstance().getReference();
mDatabase.child("userviews").child("first").setValue(viewedUsers);
if I doing like this, I am getting following format.
"userviews" :{
"first":{
"userEmail":"abc@gmail.com"
}
}
Model Class : ViewedUser
public class ViewedUsers {
public String getUserEmail() {
return userEmail;
}
public void setUserEmail(String userEmail) {
this.userEmail = userEmail;
}
String userEmail;
}