Slaknation
Slaknation

Reputation: 1936

Android Firebase Firestore: Add data every time user changes input?

I have this Android Application that saves everything to shared preferences every time the user changes data. It is very small data (like checkboxes for booleans, some user input ints, etc.). I want to make my application save everything to the cloud now. That way, users can login on a different phone or something and still see everything. I am using Firebase's Firestore. I am wondering if it would be good practice to update the database everytime the user changes something, or if I should add a button that users can use to save everything to the Firestore. Also, I want to know if it would be wise to just get rid of shared preferences since I am saving everything to the cloud now or if it would still be useful.

Upvotes: 1

Views: 286

Answers (1)

Gastón Saillén
Gastón Saillén

Reputation: 13179

I am wondering if it would be good practice to update the database everytime the user changes something, or if I should add a button that users can use to save everything to the Firestore.

This is more of opinion based, so for me it will be better to just use the real time advantage that Firestore has, since putting simple values inside the database won't be much of a waste of resources, it will be better for your UX since you don't need to get them press a button to save all the data, but in another scenario if your users are filling some form, that will be just fine since they complete the form and then press the save all button to send all the configuration.

Also, I want to know if it would be wise to just get rid of shared preferences since I am saving everything to the cloud now or if it would still be useful.

If you plan to have this data offline too , it will be a good practice to store them too into SharedPreferences and put a method that checks if the internet connection is available or not, if not, just restore the user settings with the latest ones from SharedPrefs, since when you press the save button the data will be sync into Firestore and also to your sharedPrefs. If your users uninstalls the app they will have the data stored online, whenever they download or install again the app the settings will be there, but if there is no internet your users can use the latest values stored at sharedprefs.

Upvotes: 2

Related Questions