Hi I am trying to update the firebase Realtime database.
I am able to successfully do this operation but the problem I am having is when I finish this operation I call notifyDataSetChanged()
to update the recycler view although it doesn't work.
What ends up happening is that it creates duplicate rows. I have to manually refresh the activity to see the UI change take effect.
Usually when I call notifyDataSetChanged()
the UI updates but it isn't for some reason.
Can anyone please help?
DatabaseReference databaseReference = FirebaseDatabase.getInstance().getReference("Student").child(students.get(adapterPosition).getStudentID()).child(students.get(adapterPosition).getDatabaseSnapshotValue());
databaseReference.child("StudentAge").setValue(Integer.parseInt(age));
databaseReference.child("StudentName").setValue(newName);
new Handler(Looper.getMainLooper()).post(() -> {
notifyDataSetChanged();
});