Android/Firebase - store firebase data in background for use on UI instead of loading new data when an activity is started

Android/Firebase - store firebase data in background for use on UI instead of loading new data when an activity is started



I would like to know, what is the best way to store data from a firebase data in the background of my android app so that it can be used on the UI at any time.


Currently I am accessing the database and then applying the data to the UI within public void onActivityCreated in my fragment but it takes a few seconds to load the data meaning that every time the user accesses this fragment, they are sat waiting for the data to load.

I feel like it would be better for the user if the data was stored somewhere in the background so it could be used instantly at any time in order to reduce loading times but I'm not really sure how to go about it.

Any help appreciated, thanks.


public void onActivityCreated




1 Answer
1



I discovered what I was looking for was the singleton pattern.



Singleton in Android



https://code.tutsplus.com/tutorials/android-design-patterns-the-singleton-pattern--cms-29153






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Help:Category

How can temperature be calculated given relative humidity and dew point?

I have a recursive function to validate tree graph and need a return condition