Below is the code snippet for it
public class Member {
private String name; //name of the member
private String ID; //email for e.g
private Map timestamp;
private String fireBaseKey;
public String getName(){return this.name;}
public String getID(){return this.ID;}
public Map getTimestamp() {return timestamp;}
public String getFireBaseKey(){return this.fireBaseKey;}
public void setName(String name){this.name = name;}
public void setID(String ID){this.ID = ID;}
public void setTimestamp(Map ts) {this.timestamp= ts;}
public void setFireBaseKey(String key){this.fireBaseKey = key;}
}
public class Member {
private String name; //name of the member
private String ID; //email for e.g
private Map timestamp;
private String fireBaseKey;
public String getName(){return this.name;}
public String getID(){return this.ID;}
public Map
public String getFireBaseKey(){return this.fireBaseKey;}
public void setName(String name){this.name = name;}
public void setID(String ID){this.ID = ID;}
public void setTimestamp(Map ts) {this.timestamp= ts;}
public void setFireBaseKey(String key){this.fireBaseKey = key;}
}
Map map = new HashMap();
map.put("timestamp", ServerValue.TIMESTAMP);
Member member = new Member();
member.setID(userID);
member.setName(name);
member.setTimestamp(ServerValue.TIMESTAMP);
DatabaseReference databaseReference = FirebaseDatabase.getInstance().getReference();
String pathName = APP_NAME + "/" + conversation.getConversationPath();
final DatabaseReference messagesRef = databaseReference.child(pathName).child(conversation.getFbRecordKey()).child("members");
messagesRef.push().setValue(member);
No comments:
Post a Comment