I have a RecyclerView in MainActivity that loads saved data from database using Android Architecture Components (Room), this data is then passed to ChildActivity via intent as a parcellable bundle. I wish to be able to delete this data upon button click from ChildActivity: the issue I have now is to get the RecyclerView holder position in order to delete this particular part of the RecyclerView data. I am aware this is easier by swipe to delete from MainActivity, but I don't want to do that since I will be deleting from ChildActivity upon button click from the context.
I have come up with the below method, but it's not just working;
public void deleteMovie( RecyclerView.ViewHolder viewHolder){
int position = viewHolder.getAdapterPosition();
List<DataObject> movie = mAdapter.getMovieList();
mDb.dataDao().deleteData(movie.get(position);
}
I don't know where to go from here. This method works well for overriden onSwipe method of itemTouchHelper class, but this is not my intention.
Kindly help bail me out.