I have a data base reference and in that I have the details of the announcement, but actually when a new announcement is added to the existing database, it gets displayed way below the last element, I want it to be on the top.
Here is the code for reading announcement from DB
demo= FirebaseDatabase.getInstance().getReference().child("IDS").child("/News");
demo.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for(DataSnapshot snapshot : dataSnapshot.getChildren()) {
RvClass rvClass = snapshot.getValue(RvClass.class);
list.add(rvClass);
}
CustomAdapter adapter = new CustomAdapter(SubmitNews.this,list);
rv.setAdapter(adapter);
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
After fetching the data I displayed it in a RecyclerView , all functionality is fine except the newly added announcement, it is getting placed at the last.
Thank you!