Android Firebase Checking if Data is Equal To String

后端 未结 1 1663
日久生厌
日久生厌 2021-01-27 12:38

I am using firebase to store information into the database to store favorites. I basically have a listview and when you click on an item it will take you to a new activity. I wa

相关标签:
1条回答
  • 2021-01-27 13:19

    Change this:

     if ((myRef.child("Favorites").child(itemName.toLowerCase())).equals(itemName.toLowerCase())) {
    

    To this:

    FirebaseDatabase firebaseDatabase = FirebaseDatabase.getInstance();
    DatabaseReference myRef = firebaseDatabase.getReference(firebaseAuth.getCurrentUser().getUid());
    Query queries=myRef.child("ItemName").orderByChild("name").equals(itemName);
    

    You need to use orderByChild("name").equals(itemName) to check if the child in the database has that value. Also the child(child_here) needs to be the same name as in the database.

    More info here

    0 讨论(0)
提交回复
热议问题