title: Android RecyclerView set Adapter works but notifyDatasetchanged() does not in fragment
body: <p>I am using the <code>Observer</code> class to update my <code>RecyclerView</code> whenever a new item is added to the list. Following is my code -</p>
  
  <pre><code>Observer&lt;List&lt;StudentEntity&gt;&gt; myObserver = new Observer&lt;List&lt;StudentEntity&gt;&gt;() {
              @Override
              public void onChanged(@Nullable List&lt;StudentEntity&gt; studentEntities) {
                  //Update Listview adapter
                  lstStudents = studentEntities;
                  if (recyclerView.getAdapter()==null){
                      MyStudentEntityRecyclerViewAdapter  recyclerViewAdapter = new MyStudentEntityRecyclerViewAdapter(lstStudents, mListener);
                      recyclerView.setAdapter(recyclerViewAdapter);
                  }else {
                      //recyclerView.getAdapter().notifyDataSetChanged(); --- This does not work
                      MyStudentEntityRecyclerViewAdapter  recyclerViewAdapter = new MyStudentEntityRecyclerViewAdapter(lstStudents, mListener);
                      recyclerView.setAdapter(recyclerViewAdapter);
                      Toast.makeText(getContext(),"New record added",Toast.LENGTH_SHORT).show();
  
                  }
              }
          };
  </code></pre>
  
  <p>In the if condition when I used <code>notifydatasetchanged()</code> the adapter is re-drawing itself but with the old data. However, when I using setAdapter method it works fine. Can you please explain?</p>