How I Can Get Data Of Next Child And Show It In List View From Firebase Realtime Database
I am developing an Audio Hadith, now I want to show the first key as a category like Ramadan, Zakat etc and in every category, there will lot of audio hadith's title and audio URL.
Solution 1:
You cannot query your actual database structure for getting all Hadith
objects in one go because each one of those object exists in a separate node. To solve this, I recommend you change your database strucuture by reducing the number of nodes like this:
Firebase-root
|
--- Hadiths
|
--- hadith1
| |
| --- title: "This is hadith1 title"
| |
| --- url: "eg.example.com"
| |
| --- type: "Ramadan"
|
--- hadith2
|
--- title: "This is hadith2 title"
|
--- url: "eg.example.com"
|
--- type: "Zakat"
Now, to query all hadiths for Ramadan, please use the following query:
DatabaseReferencerootRef= FirebaseDatabase.getInstance().getReference();
Queryquery= rootRef.child("Hadiths").orderByChild("type").equalTo("Ramadan");
query.addListenerForSingleValueEvent(/* ... */);
Post a Comment for "How I Can Get Data Of Next Child And Show It In List View From Firebase Realtime Database"