How to add multiple values under the same key for FireBase?

Viewed 8486

How do I add multiple values for the same key in Firebase? When I do the following to add data to my database, the objects are just replacing each other.

    Map<String,Object> taskMap = new HashMap<>();
    taskMap.put("age", "12");
    taskMap.put("gender", "male");
    taskMap.put("age", "45");
    taskMap.put("gender", "female");
    reference.setValue(taskMap);

The data in Firebase only displayed age 45, and gender female. It overrode the age 12 and gender male. How do I have both?

1 Answers
Related