The database structure that you are following is a bit messy and can be a little difficult to navigate. May I suggest: -
Users{ userID_1 : { username : "Shelly Morgan" , useremail : " sehlly1@yahoo.co.in " friends :{ userID_2 : true, userID_3 : true, userID_4 : true, } }, userID_2 : { username : "Mikael" , useremail : " mike1232@gmail.com " friends :{ userID_1 : true, userID_4 : true, } }, userID_3 : { username : "Lenoard Narish" , useremail : " leo_nar12@gmail.com " friends :{ userID_1 : true, userID_2 : true, userID_4 : true, } }, userID_4 : { username : "Rob Stark" , useremail : " robStar781@gmail.com " friends :{ userID_1 : true } } }
That way, you only userID friends in this user database, and all you have to do is change the values ββonly in the friends_uid node. To get the friends database: -
1.) just click friends node of that User
2.) listen to all uid friends,
3.) and delete the database with the desired uid to get the database of the corresponding friend
Read the data mining documentation here: https://firebase.google.com/docs/database/android/retrieve-data
source share