Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

retrieve values greater than particular value from firebase realtime databasein android

image

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 ?

like image 447
Darshan Joshi Avatar asked Mar 23 '17 04:03

Darshan Joshi


People also ask

How to retrieve data from Firebase Realtime Database in Android?

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 ...

What is Firebase and why is it so popular?

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.

How to add data to Firebase from a null value?

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”.

How to add data to a text view in Firebase?

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.


1 Answers

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).

like image 107
Frank van Puffelen Avatar answered Oct 19 '22 21:10

Frank van Puffelen