I have a local database in Android with some data that contains timestamp. And I have a firebase database that contains same data. Now if I update data in firebase database, suppose I update name and timestamp updated automatically. App also maintains last sync time in preference.
How do I retrieve all data from firebase where timestamp in firebase is greater than timestamp in preference ?
How to Retrieve Data from the Firebase Realtime Database in Android? Step 1: Create a new Project To create a new project in Android Studio please refer to How to Create/Start a New Project... Step 2: Connect your app to Firebase After creating a new project, navigate to the Tools option on the top ...
The feature for which Firebase is famous is for its Firebase Realtime Database. By using Firebase Realtime Database in your app you can give live data updates to your users without actually refreshing your app.
Hover your cursor on null and click on the “+” option on the right side and click on that option. After clicking on that option. Add the data as added in the below image. Make sure to add “Data” in the Name field because we are setting our reference for Firebase as “Data” in our code on line 55. So we have to set it to “Data”.
This will be the string which we are going to display inside our text view. After adding data click on the add button and your data will be added in Firebase and this data will be displayed in your app.
Something like this:
Query query = ref.orderByChild("lastUpdatedTimestamp").startAt("1490187991");
I'm not sure why you store the timestamp as a string btw. I recommend converting that to a number, so that you don't get caught when we reach the 11th digit (which admittedly will take quite some time).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With