How to update Activiti or Fragment from Adaptara? recreate(); or getActivity().recreate(); It does not work here.

When you click on a list item, the code for deleting this object from the database is registered in the adapter. So if you click on any item, the object is deleted from the database, but to see that it is not there, you need to exit and enter, in other words, reload

  • You need to update not all activations, but only a list widget (recyclerview / listview) for this, the adapter has methods that begin on notify .. - pavlofff

2 answers 2

CursorLoader + ContentProvider is best suited for you, the data will be updated when the database changes.

  • I use ORM Sugar, CursorLoader as I understand it for SQLite - Artsait

Try notifyDataSetChanged () after uninstalling

  • I tried, but it doesn't work out - Artsait
  • And you before notifyDataSetChanged remote record from the database, from the array from which you take the data for display, delete? - incr
  • In the activation, I load, the data in the list, then the list is loaded into the adapter, I already delete the adapter from the database, as I understand, it’s better to load the adapter directly from the database, but the architecture itself needs to be rewritten. While I think how best to do it. I understand that through the adapter you can not reload the fragment? - Artsait
  • In the fragment itself, I add getActivity () to recreate () after adding to the database; The fragment is updated and a new item appears in the list. The problem is that I have more than one table in the database, but 49 and depending on what data the fragment receives, a certain table is filled. And so if there would be one table, then it could simply be sent directly to the adapter - Artsait
  • one
    It is better to use notifyItemRemoved, delete the entry from the database, delete from the list in the adapter, call notifyItemRemoved. - incr