title: Passing data from list fragment to new activity
body: <p>Am trying to pass data from list fragment in an activity to a new activity and getting null...</p>
  
  <p>Here is my recyclerview adapter code...</p>
  
  <pre><code>package com.doctorapp.doctor;
  
  import android.app.LauncherActivity;
  import android.content.Context;
  import android.content.Intent;
  import android.support.v7.widget.RecyclerView;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.AdapterView;
  import android.widget.TextView;
  import android.widget.Toast;
  import android.util.Log;
  
  import com.doctorapp.doctor.MyPatientsFragment.OnListFragmentInteractionListener;
  import com.doctorapp.doctor.dummy.DummyContent.DummyItem;
  
  import java.util.List;
  
  /**
   * {@link RecyclerView.Adapter} that can display a {@link DummyItem} and makes a call to the
   * specified {@link OnListFragmentInteractionListener}.
   * TODO: Replace the implementation with code for your data type.
   */
  public class MypatientsRecyclerViewAdapter extends RecyclerView.Adapter&lt;MypatientsRecyclerViewAdapter.ViewHolder&gt; {
  
      private final List&lt;MyPatientsItem&gt; mValues;
      private final OnListFragmentInteractionListener mListener;
      private Context context;
  
      public MypatientsRecyclerViewAdapter(List&lt;MyPatientsItem&gt; items, OnListFragmentInteractionListener listener) {
          mValues = items;
          mListener = listener;
      }
  
      @Override
      public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
          View view = LayoutInflater.from(parent.getContext())
                  .inflate(R.layout.fragment_patients, parent, false);
          return new ViewHolder(view);
      }
  
      @Override
      public void onBindViewHolder(final ViewHolder holder, final int position) {
  
          holder.mypatientsItem = mValues.get(position);
          holder.txtPatientName.setText(mValues.get(position).getPatient_name());
  
          holder.mView.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  int patient_id = mValues.get(position).getPatient_id();
                  Toast.makeText(v.getContext(), "My Position : "+ patient_id, Toast.LENGTH_LONG).show();
                  Intent i = new Intent(context, PatientProfile.class);
                  i.putExtra("patient_id", patient_id);
                  context.startActivity(i);
                  if (null != mListener) {
                      //Toast.makeText(v.getContext(), "Am clicked.hey", Toast.LENGTH_LONG).show();
                      // Notify the active callbacks interface (the activity, if the
                      // fragment is attached to one) that an item has been selected.
                      mListener.onListFragmentInteraction(holder.mypatientsItem);
                      //Toast.makeText(v.getContext(), "Am clicked.", Toast.LENGTH_LONG).show();
  
                  }
              }
          });
      }
  
  
      @Override
      public int getItemCount() {
          return mValues.size();
      }
  
      public class ViewHolder extends RecyclerView.ViewHolder {
          public final View mView;
          public final TextView txtPatientId;
          public final TextView txtPatientName;
          public MyPatientsItem mypatientsItem;
  
          public ViewHolder(View view) {
              super(view);
              context = view.getContext();
              mView = view;
              txtPatientId = (TextView) view.findViewById(R.id.patient_id);
              txtPatientName = (TextView) view.findViewById(R.id.patient_name);
          }
  
          @Override
          public String toString() {
              return super.toString() + " '" + txtPatientName.getText() + "'";
          }
      }
  }
  </code></pre>
  
  <p>The list is populating fine and when I click it is also giving me toast with the right ID that needs to be passed so that the next activity can populate data for the right patient. In the second activity where I want to get data, it is giving null in all the ways I tried...</p>
  
  <p>here is the code...</p>
  
  <pre><code>   protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_patient_profile);
          Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
          setSupportActionBar(toolbar);
  
  
          //String patient_id_str = (String) savedInstanceState.getSerializable("patient_id");
  
          Intent intent = getIntent();
          String patient_id_str = intent.getStringExtra("patient_id");
  
          Toast.makeText(getApplicationContext(), "Load Patient : " + patient_id_str, Toast.LENGTH_LONG).show();
  
  
          FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
          fab.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                          .setAction("Action", null).show();
              }
          });
      }
  </code></pre>
  
  <p>it always returns me null... am new to android and learning stuff with tutorials online so kind of hard for me to understand why it is not happening as many posts on the internet says this should work. please advise me on where am making mistake.</p>