Skip to content
Advertisement

how I can get data from the firebase database without repeat

I am developing a android app work with the firebase database , when the user add item to the database the app display it at the Realtime and that what I want , but the problem it is that same item show more than one time in the RecyclerView this is the code that I try

JavaScript

But it does not solve it ,and a side note when I go out from the app and enter again it is works perfectly and show the items without repeat anyone ,How can I solve that ?

Advertisement

Answer

What happening is the ArrayList is getting data added every time listener returns the data. To remove duplicacy just clear the arrayllist inside the onDataChange() function

JavaScript

Hope your bug is resolved.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement