From your explanation this seems to be an issue which can be easily solved by keeping the app running in background. For this purpose look here.
Quoting the answer from above link I gave here,
A very simple answer for your problem is to use Service. It will allow you to perform variety of tasks while being in background and is your best bet for sending your location/data to server silently.
Also read this answer for help.
Although both the answers are related to location update but they can be easily extended to fulfill your requirements.
Hint:
The above quoted answers are sending the data to a server at frequent intervals. Send your data to Firebase server when the data-field is changed.