Skip to content Skip to sidebar Skip to footer

Abstract Firebase From Android Ui

I'm facing with issue that Firebase as Realtime Database works great while we connect it with Activity or Fragment. But trying to separate from view elements and create some abstra

Solution 1:

There should be no inherent coupling between Firebase and UI (unless you're using FirebaseUI). Typical solution would be to encapsulate firebase database access in some kind of Service/DAO class (injected in to UI classes using Dagger for example)....and have methods in that class return RxJava Observable (this also nicely enables making sets of nested firebase queries....for example if doing something equivalent to a "join")

Solution 2:

Just save a string value in your resources and save your DB path Then when you create a DatabaseReference use that value to point to the base of either your real or test DB

Post a Comment for "Abstract Firebase From Android Ui"