Firebase behaves strangely
When you are using the Query#addValueEventListener() method, it means that you are listening for real-time updates (changes). That being said, every change that takes place in the Realtime Database that corresponds to your referencia
query, will always trigger the onDataChange()
method. Since when you are adding data inside the callback to the query you are listening to, your sendToDataBase
gets written again, hence that behavior. This is happening over and over again.
To solve this, simply change the above method call to Query#addListenerForSingleValueEvent(). This means that it will listen for changes only once.