android - Should FirebaseDatabase.getInstance() be used sparingly? -


for example when use sqlitedatabase in android, not idea open/close lots of sqlitedatabase helpers. instead better create sort of singleton makes sure have 1 database open.

say have class static methods doing lots of firebase operations require databasereference. example:

static void checkifuserismatched(...) static void notifyuser(...) static void modifyuser(...) 

is ok call firebasedatabase.getinstance() inside every method? create new databasereference inside each method?

or better pass databasereference calling activity?

static void notifyuser(muserreference, hisuserid) 

vs

static void notifyuser(myuserid, hisuserid) --> create reference inside method 

what im looking optimize network usage , performance. or not matter , firebase handle me?

firebasedatabase , databasereference objects can considered relatively cheap references underlying resources.

the firebase sdk manages such things behind scenes. first call firebasedata.getinstance() set work, subsequent calls (within same process) re-use done already.


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -