1

I have searched far and wide on stackoverflow like HERE and HERE Before you point me to THIS solution or THIS solution, I want to insert item into the database from say a dialog and call notifyItemInserted, I would like to Swipe to Delete with the ItemTouchHelper.Callback and call the appropriate notifyItemRemoved method, I would like to actually delete multiple items at random positions as well and call either notifyItemChanged for each of those positions or notifyItemRangeChanged in bulk, both the solutions that most people have pointed out call notifyDataSetChanged, what is the best way for me to call nofifyXXX methods on my RecyclerView.Adapter implementation and keep SQLite as the data source for my Adapter?

Community
  • 1
  • 1
PirateApp
  • 5,433
  • 4
  • 57
  • 90
  • [notifyDataSetChanged](http://developer.android.com/intl/vi/reference/android/support/v7/widget/RecyclerView.Adapter.html#notifyDataSetChanged()) - *If you are writing an adapter it will always be more efficient to use the more specific change events if you can. Rely on notifyDataSetChanged() as a last resort.* – kientux Nov 05 '15 at 16:28
  • kientux, can you give any sample code for this, I have seen people write a custom RecyclerView.Adapter based on the source code of the original CursorAdapter but they use notifyDataSetChanged() everywhere which is why I posted the 2 common solutions above... – PirateApp Nov 05 '15 at 16:31
  • You want to delete random items, then loop through those items and call `notifyItemRemoved(position)`. If you want to insert, just call `notifyItemInserted(position)`. – kientux Nov 05 '15 at 17:05

0 Answers0