'Firebase realtime database hiscore
I want to get user's data (like nickname,country) who is champion. In my example I want to get data of nickname3 because who has 863 hiScore.It means nickname3 is champion.
I tried some thing but it is not working. In my opinion firstly I should find the champion's reference. After finding reference of champion, I can try get values of children of champion.
Can you help me. How can I get the values of the champion.
What I tried is
override fun getHiScoreInFirebase(interfaceCallback: InterfaceCallback) {
var ref=FirebaseDatabase.getInstance().reference.child("user").orderByChild("HiScore").limitToLast(1).ref
ref.addValueEventListener(object : ValueEventListener {
override fun onDataChange(dataSnapshot: DataSnapshot) {
if(dataSnapshot.exists()){
val hiScore= dataSnapshot.child("HiScore").getValue() as Int
val kullaniciAdi= dataSnapshot.child("KullaniciAdi").getValue() as String
val sehir= dataSnapshot.child("Sehir").getValue() as String
val ulke= dataSnapshot.child("Ulke").getValue() as String
interfaceCallback.hiScoreSonucCallback(hiScore,kullaniciAdi,ulke,sehir)
}}
override fun onCancelled(error: DatabaseError) {
}
})}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

