This is the link for image
I want to get the msg from the above data where sender equals to salam..can any body help me out how to write query in firebase database(Android)..I am new to this firebase..
The query will be pretty straightforward, but there are multiple ways you can implement the query listeners depending on your use case. If you only want to read your data once, you can setup the following query.
DatabaseReference ref = FirebaseDatabase.getInstance().getReference();
ref.child("messages").orderByChild("sender").equals("salam")
.addListenerForSingleValueEvent(new ValueEventListener({...}));
See https://firebase.google.com/docs/database/android/read-and-write for the startup tutorial and https://firebase.google.com/docs/reference/android/com/google/firebase/database/DatabaseReference for the full documentation.
Related
I am working on a android Firebase project. I need help in implementing this sql query in Firebase real-time database.
SELECT * FROM table
WHERE price BETWEEN $min AND $max;
There's good documentation on how to do firebase queries as well as apply them to ranges.
Something like:
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference ref = database.getReference("table");
Query query = ref.orderByChild("price").startAt(min).endAt(max);
Then you add the appropriate listener for what you are trying to do. (e.g. a ValueEventListener or a ChildEventListener via addValueEventListener or addChildEventListener respectively.
You can use the following method
new Firebase("https://examples-sql-queries.firebaseio.com/messages")
.startAt(startTime)
.endAt(endTime)
.once('value', function(snap) {
console.log('messages in range', snap.val());
});
Hi,
I have this problem in query in Firebase. The orderbykey() and orderbychild() doesn't work. How do I query this one?
cheers, thanks in advance.
Code Snippet:
Query mRef = mRootRef.child("Messages").orderByKey().equalTo(mAuth.getCurrentUser().getUid());
Query mRef = mRootRef.child("Messages").orderByChild("commWith").equalTo(mAuth.getCurrentUser().getUid());
i have just re design my JSON at firebase like in the image below, so that i could simply get the unique keys per data
I want to fetch the specific data from the firebase into the android app.
I want to be fetch only that data where ar="Atif Aslam". How I can do that?
This is my database
try the following code:
DatabaseReference mDatabaseReference = FirebaseDatabase.getInstance().getReference("uploads");
Query query
= mDatabaseReference.orderByChild("ar").equalTo("Atif Aslam");
refer examples from firebase official site:https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query
Hope this helps.
Try using firebase.database.Query
Query msgQuery = childRef.orderByChild("ar").equalTo("Atif Aslam");
msgQuery.addChildEventListener(MainActivity.this);
I am using Firebase realtime DB in my app,I could not use multiple order by in my query.If i am not use that one,looping the data again and again.It leads my app run slow.So please help me how to do that.Otherwise how to get multiple items in single Query
DatabaseReference reference = FirebaseDatabase.getInstance().getReference();
Query query = reference.child("issue").orderByChild("id").equalTo(0,1,3);
...Like,is it possible????
I have the following structure saved in my database:
What I want is I want the databaseReference to recognise the entire node using only the unique imageUIDh and display the content of all fields like postedAtTime, postedOnDate etc.
Is this possible in Firebase? Is there some alternative to achieve what I want?
Please let me know.
You can use Query
ref = FirebaseDatabase.getInstance().getReference();
ref.orderByChild("imageUIDh").equalTo(imageUIDh).addValueEventListener(valueEventListener);
Hope this helps :)