title: How to get value from adapter to activity on recyclerview item click event in Android?
body: <p>I'm learning <code>RecyclerView</code> and I built an app that can populate simple data from <code>SQLite database</code>
  I have an Adapter as follows :-</p>
  
  <pre><code>public class BookAdapter extends RecyclerView.Adapter&lt;BookAdapter.BookViewHolder&gt; {
  Context mContext;
  Cursor mCursor;
  OnBookListener mOnBookListener;
  public int id;
  
  public BookAdapter(Context context, Cursor cursor, OnBookListener onBookListener){
      mContext = context;
      mCursor = cursor;
      mOnBookListener = onBookListener;
  
  }
  public class BookViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
      public TextView id_textView, name_textView;
      OnBookListener onBookListener;
  
      public BookViewHolder(@NonNull View itemView, OnBookListener onBookListener) {
          super(itemView);
  
          id_textView = itemView.findViewById(R.id.book_id);
          name_textView = itemView.findViewById(R.id.book_name);
          this.onBookListener = onBookListener;
          itemView.setOnClickListener(this);
      }
  
      public String getId_textView() {
          return (String)id_textView.getText();
      }
      public String getName_textView() {
          return (String)name_textView.getText();
      }
  
      @Override
      public void onClick(View v) {
         onBookListener.onBookClick((String)id_textView.getText());
          //Log.d(TAG, "onBookClick : Clicked " + id_textView.getText());
      }
  }
  
  public interface OnBookListener{
      void onBookClick(String id);
  }
  
  @NonNull
  @Override
  public BookViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
      LayoutInflater inflater = LayoutInflater.from(mContext);
      View view = inflater.inflate(R.layout.book_item,parent,false);
      return new BookViewHolder(view, mOnBookListener);
  }
  
  @Override
  public void onBindViewHolder(@NonNull BookViewHolder holder, int position) {
      if(!mCursor.moveToPosition(position)){
          return;
      }
  
      id = mCursor.getInt(mCursor.getColumnIndex(Book.BookEntry.COLUMN_ID));
      String name = mCursor.getString(mCursor.getColumnIndex(Book.BookEntry.COLUMN_NAME));
  
      holder.id_textView.setText(String.valueOf(id));
      holder.name_textView.setText(name);
  
      if(position %2 == 1)
      {
          holder.itemView.setBackgroundColor(Color.parseColor("#E9EEF3"));
      }
      else
      {
          holder.itemView.setBackgroundColor(Color.parseColor("#0FA9E8"));
      }
  
  }
  
  @Override
  public int getItemCount() {
      return mCursor.getCount();
  }
  
  public void swapCursor(Cursor newCursor){
      if(mCursor != null){
          mCursor.close();
      }
      mCursor = newCursor;
  
      if(newCursor != null){
          notifyDataSetChanged();
      }
  }
  </code></pre>
  
  <p>now with the Activity itself :</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity implements BookAdapter.OnBookListener {
  
      public SQLiteDatabase mdatabase;
      public BookAdapter madapter;
      private static final String TAG = "MainActivity";
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          //SqliteDBHelper dbHelper = new SqliteDBHelper(this);
          SqliteAssetHelper dbHelper = new SqliteAssetHelper(this);
          mdatabase = dbHelper.getReadableDatabase();
  
          RecyclerView recyclerView = findViewById(R.id.recycler_view);
          recyclerView.setLayoutManager(new LinearLayoutManager(this));
          madapter = new BookAdapter(this, getAllBooks(), this);
          recyclerView.setAdapter(madapter);
  
          madapter.swapCursor(getAllBooks());
      }
  
      private Cursor getAllBooks(){
          return mdatabase.query(Book.BookEntry.TABLE_NAME,null,null,null
          ,null,null,null);
      }
  
  
      @Override
      public void onBookClick(String id) {
          Intent intent = new Intent(this, HadithsList.class);
          intent.putExtra("id", ???);
          startActivity(intent);
      }
  </code></pre>
  
  <p>What code can I replace the question marks in the above intent to actually get the <code>id</code> from the <code>interface : OnBookListener</code> That is implemented in the activity.
  Thanks in advance</p>