Retrieving data from Firebase Realtime Database in Android

前端 未结 3 1056
情歌与酒
情歌与酒 2020-12-03 22:45

I\'m new to Firebase and NoSQL. I have an Android Demo, with a City Autocomplete Text Field in which I want to populate the cities I have from my Firebase DB, while typing.<

3条回答
  •  再見小時候
    2020-12-03 23:16

    Of course OrderByValue returns nothing because that's the booleans you have.

    you can use the startAt and endAt methods to do so. (The below is Firebase 2.0's Code)

    var ref = new Firebase("https://dinosaur-facts.firebaseio.com/dinosaurs");
    ref.orderByKey().startAt("b").endAt("b\uf8ff").on("child_added", function(snapshot) {
      console.log(snapshot.key());
    });
    

    You can explore more on the Firebase 3 documentation site here.

    What Ryan did was right. However, you have to implement startAt on the dataSnapshot to make sure that your "live" search works.

提交回复
热议问题