I want to add the array of LatLng in my firebase database. I have added my title and data in my database but can't get the knowledge of storing array in my database.
I have gone through this link but my problem is to stora array.
//To write in database.
@Override
public void writeNewPost(ArrayList<LatLng> latLng, DatabaseReference mDatabase,
Events model, User user) {
final String userId = FirebaseAuth.getInstance().getCurrentUser().getUid();
String key = mDatabase.child("events").push().getKey();
Events events = new Events(userId, user.username, model.getEventTitle(),
model.getEventDateTime() latLng);
Map<String, Object> eventsValues = events.toMapEvents();
Map<String, Object> childUpdates = new HashMap<>();
childUpdates.put("/events/" + key, eventsValues);
this.key = key;
mDatabase.updateChildren(childUpdates);
}
//Model
public Map<String, Object> toMapEvents() {
HashMap<String, Object> result = new HashMap<>();
result.put("userId", userId);
result.put("username", username);
result.put("eventTitle", eventTitle);
result.put("eventDateTime", eventDateTime);
//What to do
return result;
}
How can i store my array in firebase?
Thanks .