title: Replacement for OnItemClickListener for cardview in order to delete item from SQLite Database
body: <p><strong>What I want :</strong> To delete a clicked contact both from cardview as well as it's respective sqlite entry.</p>
  <p><strong>The problem :</strong> I've been following <a href="https://youtu.be/312RhjfetP8?t=5141" rel="nofollow noreferrer">this</a> tutorial on how to create a basic SQLite Database. While I was able to add elements to the database. I am having trouble removing them via a dedicated delete button for each contact item cardview because in the tutorial they seem to use setOnItemClickListener which I've discovered does not work on recyclerview.</p>
  <p>This is the code that was supposed to be written. Where I had to replace CustomerModel with ContactInfo for my project.
  <a href="https://i.stack.imgur.com/9r9gE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9r9gE.png" alt="Required Code" /></a></p>
  <pre><code>lv_customerlist.setOnItemClickListener(new AdapterView.OnItemClickListener() {
  @Override 
   public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
   CustomerModel clickedCustomer = (CustomerModel) parent.getItemAt Position (position);
   dataBaseHelper.deleteOne(clickedCustomer);
   ShowCustomers OnListView(); 
   Toast.makeText( context: MainActivity.this, text: &quot;&quot;, Toast. LENGTH_SHORT).show();
  });
  </code></pre>
  <p>This is my current cardview with the deletebutton with a simple toast.</p>
  <pre><code>            mDelete.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
               Toast.makeText(context, &quot;Contact Deleted&quot;, Toast.LENGTH_SHORT).show();
              }
  
          });
  </code></pre>
  <p>This is the DatabaseHelper's delete method</p>
  <pre><code>    public boolean deleteOne(ContactInfo Contactinfo){
      //if ContactInfo exists, it finds,deletes and returns true.
      //if not found return false.
      SQLiteDatabase db = this.getWritableDatabase();
      String queryString = &quot; DELETE FROM &quot; + CONTACT_LIST + &quot; WHERE &quot; + COLUMN_ID + &quot; = &quot; + Contactinfo.getId();
  
      Cursor cursor = db.rawQuery(queryString, null);
      if(cursor.moveToFirst()){
          return true;
      }
      else {
          return  false;
      }
  }
  </code></pre>
  <p>how can I link these two so that my item gets removed both from the cardview as well as the database ?</p>
  <p>Would really appreciate it if someone could guide me in the correct way.</p>