How to get id data from database deleting - setOnLongClickListener ERROR

you have in your code

arrayList.remove(position);

then few lines below

dbId = arrayList.get(position).id; // <---the error is in this code

your array list is empty after remove call, but you are still trying to get this item at position, thus you are getting IndexOutOfBoundsException: Index: 0, Size: 0 - you are trying to obtain item at position = 0 and array is empty

try to move obtaining dbId BEFORE removing from array

            dbId = arrayList.get(position).id;
            arrayList.remove(position);
            notifyItemRemoved(position);
            //notifyItemRangeChanged(position,arrayList.size()); // this line is unnecessary