title: How do I pass data from adapter to mainactivity when a button is clicked
body: <p>I Uploaded some data to sqlite and I want to delete each data from the recyclerview by pressing a button. so how can I achieve this? I want to get the id from recyclerview to the mainactivity then delete the data from sqlite and update reyclerview. How can I achieve this?</p>
  
  <p><strong>MainActivity</strong></p>
  
  <pre><code>public class SelectedProblems extends AppCompatActivity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_selecte_problem_drawal);
  
      mRecyclerView = (RecyclerView) findViewById(R.id.selected_problem_recycle_view); // Instantiate Recyclerview
      LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
      mRecyclerView.setLayoutManager(linearLayoutManager);
      mRecyclerView.setHasFixedSize(true);
      selectedProblemsAdapter = new SelectedProblemsAdapter(this, getAllItems(),  listener);
      mRecyclerView.setAdapter(selectedProblemsAdapter);
  
     Button remove = findviewbyid(R.id.remove);
     remove.setOnClickListener(new View.OnClickListener() {
  
     }
    }
  </code></pre>
  
  <p><strong>SelectedProblemsAdapter</strong></p>
  
  <pre><code>  public SelectedProblemsAdapter(Context context, Cursor cursor, OnItemClick listener) {
          this.context = context;
          this.cursor = cursor;
          listener = listener;
  
      }
  
      @Override
      public SelectedProblemsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
          LayoutInflater layoutInflater = LayoutInflater.from(context);
          View view = layoutInflater.inflate(R.layout.activity_selected_problems_content, null, false);
          return new SelectedProblemsViewHolder(view);
      }
      @Override
      public void onBindViewHolder(@NonNull SelectedProblemsViewHolder holder, final int position) {
          if (this.cursor != null){
          }
      }
  
  
      @Override
      public int getItemCount() {
          return (null != cursor ? cursor.getCount(): 0);
      }
  
      public void update(Cursor cursor) {
          this.cursor = cursor;
          notifyDataSetChanged();
      }
  
      class SelectedProblemsViewHolder extends RecyclerView.ViewHolder{
  
          TextView selectedProblems, selectedProblemPrice, selectedProblemTotal;
          Button remove_problem_from_cart;
          public SelectedProblemsViewHolder(View itemView) {
              super(itemView);
              selectedProblems = itemView.findViewById(R.id.selected_problems);
              selectedProblemPrice = itemView.findViewById(R.id.selected_problem_price);
              selectedProblemTotal = itemView.findViewById(R.id.selectedProblemTotal);
              remove_problem_from_cart = itemView.findViewById(R.id.remove_problem_from_cart);
  
          }
      }
  }
  </code></pre>