I have a similiar problem as mentoned here enter link description here
but the suggested solution does neither working for me. My recyclerview list items from an sqlite db, when i swipped to the left, the corresponding data is deleted successfully from the db. For some reason yesterday, everything worked perfectly and the deleted item disappear from the list, but since today the item is still visible in the recyclerview. Here is my code:
ItemTouchHelper.SimpleCallback itemTouchHelperCallback = new ItemTouchHelper.SimpleCallback(0,ItemTouchHelper.LEFT) {
@Override
public boolean onMove(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder, @NonNull RecyclerView.ViewHolder target) {
return false;
}
@Override
public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) {
AlertDialog deleteFileDialog = new AlertDialog.Builder(DayListActivity.this)
.setTitle()
.setMessage()
.setPositiveButton(ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
removeDay((long)viewHolder.itemView.getTag());
removeRecords((long)viewHolder.itemView.getTag());
getAllDays();//try to refresh recyclerview by calling function to
//load data from db
dayListAdapter.notifyItemRemoved(viewHolder.getAdapterPosition());
dayListAdapter.notifyDataSetChanged();
dialog.dismiss();
}
})
.setNegativeButton(R.string.file_delete_dialog_cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
}).create();
deleteFileDialog.show();
}
};