Firebase is not designed to order based on some visible index, but rather for records in the database upon request .
orderByChild , orderByKey or orderByValue
So, if you want to reorder the values ββin Firebase, you must give each element an "index" value and call orderByValue('index')
Several lines of code can update the current database items to use this index:
int index = 0; mDatabase.child("data").addChildEventListener(new ChildEventListener() { @Override public void onChildAdded(DataSnapshot dataSnapshot, String previousChildName) { Log.d(TAG, "onChildAdded:" + dataSnapshot.getKey());
source share