What do I want?
I want to retrieve the list of objects in their insertion order from Firebase Database.
How am I adding the object
Here is an example to illustrate Mr. Dima Rostopira response more clearly. Do you see the "orderByKey()"?
mFireBaseRefnew.orderByKey().addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
final Map messageMap = new LinkedHashMap();
if (dataSnapshot != null && dataSnapshot.getValue() != null) {
for (DataSnapshot postSnapshot : dataSnapshot.getChildren()) {
HashMap messageMap = (HashMap) postSnapshot.getValue();
Collection messageItems = messageMap.values() ;
List messageItemList = new ArrayList();
messageItemList.addAll(messageItems);
}
}
@Override
public void onCancelled(FirebaseError firebaseError) {
}
});