I am getting a snapspot of the data from my Firebase database to retrieve a users list, but the order of the keys being returned is different depending on the Android version/ device being used.
For demonstrative purposes I have shortened the method, but it is essentially as follows:
public void getUsers(){
Firebase ref = new Firebase("http://ift.tt/1eQ0zaI");
final Firebase userRef = ref.child("users");
userRef.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot snapshot) {
snapshot.toString();
}
});
}
It is the data I get from calling toString() on the snapshot object (snapshot.toString()) that changes order.
I have tried it on 4 devices. The 2 running Lollipop (Nexus 7 5.1.1 & Galaxy s4 5.01) return the data in the same order. And the 2 two other devices (HTC Sensation 4.0.3 and Motorola G2 4.4.4) return the data in the same order (but a different order to devices with Lollipop).
There is no difference in the code used, and the data in the database was completely unchanged at the times when I retrieved the snapshots.
Here is the data order on the 4.4.4 and 4.0.3 devices:
DataSnapshot { key = users, value = { 114585619420240714499={userIDOfCUser=114585619420240714499, NameOfCUser=testName, EmailOfCUser=testerfireapp@gmail.com, friends={103902248954972338254={userIDOfFriend=103902248954972338254, NameOfFriend=testName2 }}}
Here is the data order on the 5.1.1 and 5.01 devices:
DataSnapshot { key = users, value = {114585619420240714499={NameOfCUser=testName, userIDOfCUser=114585619420240714499, friends={103902248954972338254={NameOfFriend=testName2 , userIDOfFriend=103902248954972338254}}, EmailOfCUser= testerfireapp@gmail.com}}}
Why is the data being delivered in different orders depending on the android version/device being used? is there another difference I am unaware of ?
Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire