0

Using android studio ( android ) how to Get data from Firebase database using child value from unknown pushed key as you can see in the picture friends I'm trying to get data where

topicimage4 = 0

But I don't have the random key Firebase pushed

Firebase database

enter image description here

I searched alot about this Issue but I didn't found anything or I found questions with no answers in this website I tried also the following

myRef.child("*").orderByChild("topicimage4").equalTo("0")
myRef.child("?").orderByChild("topicimage4").equalTo("0")
myRef.orderByChild("topicimage4").equalTo("0")
myRef.orderByKey().orderByChild("topicimage4").equalTo("0")

UPDATE

here my Json tree as text

Is there any way to access to the topicimage4 child without having the Randrom key ? thnx

{
  "-L5YppUZa3dGBvDUgnYi" : {
    "paidmoney" : "400",
    "paidmoneytype" : "1",
    "topiccat" : "1",
    "topiccon" : "0",
    "topicemail" : "",
    "topicimage1" : "null",
    "topicimage2" : "null",
    "topicimage3" : "null",
    "topicimage4" : "0",
    "topicimage5" : "21",
    "topicname" : "مطلوب انسات للعمل ضمن صالون نسائي طريق عام جزين",
    "topicphone" : "70645725",
    "topicresouresname" : "",
    "topicresouresurl" : "",
    "topictext" : "في حال طلب منك الاتصال دولار اضافي على الدقيقة قم بإغلاق الخط \r\n\r\nمطلوب انسات للعمل ضمن صالون نسائي طريق عام جزين\r\n\r\n\r\nنحن نحاول قدر الامكان ضبط جميع انواع الوظائف المقدمة نشكر لكم اهتمامكم ومساعدتكم\r\n",
    "topictimed" : "17",
    "topictimeh" : "01",
    "topictimei" : "57",
    "topictimem" : "02",
    "topictimey" : "18",
    "userimage" : "0"
  },
  "-L5Yq6VJoOAN7dUKDO9O" : {
    "paidmoney" : "400",
    "paidmoneytype" : "1",
    "topiccat" : "1",
    "topiccon" : "0",
    "topicemail" : "",
    "topicimage1" : "null",
    "topicimage2" : "null",
    "topicimage3" : "null",
    "topicimage4" : "0",
    "topicimage5" : "0",
    "topicname" : "يلزمنا انسه ذات مظهر لائق",
    "topicphone" : "81614696",
    "topicresouresname" : "",
    "topicresouresurl" : "",
    "topictext" : "في حال طلب منك الاتصال دولار اضافي على الدقيقة قم بإغلاق الخط \r\n\r\nيلزمنا انسه زات مظهر لائق للعمل في اكس برس عالاوتستراد بدوام كامل للمراجعه وتس اب التفاصيل موجوده كامله\r\n\r\n\r\n\r\nنحن نحاول قدر الامكان ضبط جميع انواع الوظائف المقدمة نشكر لكم اهتمامكم ومساعدتكم\r\n",
    "topictimed" : "17",
    "topictimeh" : "01",
    "topictimei" : "58",
    "topictimem" : "02",
    "topictimey" : "18",
    "userimage" : "0"
  }
}
  • 1
    The JSON you shared doesn't have a `topicimage4` property. So I assume you want to get the topics without that property. In that case, try `FirebaseDatabase.getInstance.ref("topic").orderByChild("topicimage4").equalTo(null)`. See https://stackoverflow.com/questions/35330692/how-can-i-get-records-from-firebase-where-a-certain-field-is-empty – Frank van Puffelen Feb 17 '18 at 19:49
  • sorry i uploaded the wrong image it does have a topicimage4 property I just want a way to access the child without the random key – Mohammad Abdulsalam Feb 17 '18 at 19:57
  • 1
    Please update the JSON that you're trying to query. While you're doing that, be sure to post it as text instead of a screenshot. You've included a picture of the JSON tree in your question. You can easily get this by clicking the Export JSON link in [your Firebase Database console](https://console.firebase.google.com/project/_/database/data/). Having the JSON as text makes it searchable, allows us to easily use it to test with your actual data and use it in our answer and in general is just a Good Thing to do. – Frank van Puffelen Feb 17 '18 at 20:15
  • @FrankvanPuffelen thnx for your replay I updated my question – Mohammad Abdulsalam Feb 18 '18 at 08:23
  • It works fine i'm sorry i'm was trying to make two queries like this orderByChild("topicimage4").equalTo("0").orderByChild("topicimage3").equalTo("null") but when i removed the second query it works fine – Mohammad Abdulsalam Feb 18 '18 at 10:11
  • Firebase Database queries can only order/filter on a single property. In many cases it is possible to combine the values you want to filter on into a single (synthetic) property. For an example of this and other approaches, see my answer here: http://stackoverflow.com/questions/26700924/query-based-on-multiple-where-clauses-in-firebase. – Frank van Puffelen Feb 19 '18 at 00:09

0 Answers0