How to create group chat using firebase in android app

Megha Pawar picture Megha Pawar · Apr 8, 2017 · Viewed 9.3k times · Source

I am trying to create groups of some selected users on firebase.

But firebase creates group of all users available on firebase database. Is it possible to create group of list of users (not all) programmatically? Any hint may be very helpful to me..

Answer

ColdSpike picture ColdSpike · Apr 8, 2017

Try to add the users you need in a group under separate child. for example let one child contain all the users and then create another child in root of your database that is a group.

root
 -users
  --user1
  --user2
  --user3
 -group1
  --user1
  --user10
 -group2
  --user5
  --user3

You can add these users in different groups by either reading all the users and then sorting them in different groups or while creating the user for the first time add it to both users and any group.