Firestore.getInstance(): how to use?
I would want to query and store data, using or not listeners (to get realtime updates, etc.)
There is no way to get data or even get realtime updates without using a listener. Everything in Cloud Firestore is about listeners.
if I store this instance in a static class when my app starts and then use this static class attribute as soon as I need to query or store
Do not place Android context classes in static fields. Static reference to FirebaseFirestore which has field context pointing to Context will lead to a memory leak.
A static field will leak contexts. Non-static inner classes have an implicit reference to their outer class. If that outer class is for example a Fragment or Activity, then this reference means that the long-running handler/loader/task will hold a reference to the activity which prevents it from getting garbage collected.
So instead of storing it as a static variable call getInstance()
whenever is needed. Or a more convenient solution would to use dependency injection. Dagger can help you solve that.
And is it really safe to call getInstance whenever I need it?
Yes it is.
between 2 accesses to the static class attribute), i.e.: between 2 points of execution time, is there any risk to loose network connection, socket connection, realtime listeners (snapshots) connection, etc. ?
Please see explanation above.