So I couldn't find any clear documentation regarding the use of FirebaseDatabase.goOffline(), only general advice that this method stops the connection to Firebase, thus saving "concurrent connections" which are limited or you have to pay for them.
But I'm not sure when is your connection alive and when you should call goOffline() and goOnline(). For example, my understanding is that a call to addValueEventListener() like this would make your connection to be kept alive indefinitely listening to post changes:
ValueEventListener postListener = new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
// ...
}
// ...
}
mPostReference.addValueEventListener(postListener);
But what if you only use addListenerForSingleValueEvent() (notice Single) and other methods that should not require a continuous open connection such as
updateChildren()? I am safe that my app will not hold open connections that will count for Firebase as "concurrent connections" for more than a couple of seconds per call? (assuming decent internet connection)