DatabaseReference Ref = FirebaseDatabase.getInstance().getReference(Constants.Client + \"/\" + path);
Ref.keepSynced(true);
Ref.addValueEvent
When talking about listeners, yes, you need to remove them accordingly to the life-cycle of your activity and for this you need to use the following line of code:
databaseReference.removeEventListener(valueEventListener);
Remember if you don't do this, you'll end up wasting your battery and bandwidth. So:
onStart you have to remove it in onStop.onResume you have to remove it in onPause.onCreate you have to remove it in onDestroy.But remember onDestroy is not always called, so the last option in not always a good choice.
There is another approach in which there is no need to remove the listener and that is when using addListenerForSingleValueEvent:
Add a listener for a single change in the data at this location.