title: NullPointerException when refreshing the recyclerview
body: <p>So I have an AsyncTask class to handle populating my <code>RecyclerView</code>. It works well but when it needs to be refreshed then it crashes with a <code>NullPointerException</code>. I kind of know why but then I can't do it because I am creating a new <code>object</code> and adding it to my <code>list</code>.</p>
  
  <p>This is my code:</p>
  
  <pre><code>  @Override
          protected void onPostExecute(String s) {
              try {
                  userslist.clear();
                  JSONArray jsonArray = new JSONArray(s);
                  for(int i=0; i &lt; jsonArray.length(); i++){
                      ...
                      UsersData usersData = new UsersData(var1, var2);
                      userslist.add(UsersData);
                  }
                  cAdapter.notifyDataSetChanged(); // Culprit line, despite the list being deleted and added again in the try block
              } catch (JSONException e) {
                  e.printStackTrace();
              }
          }
  </code></pre>
  
  <p>I suspect is it something to do with the <code>userslist</code>.</p>
  
  <p>This is my error logs:</p>
  
  <pre><code>java.lang.NullPointerException
              at lukazs.newapp.UserInfo$GetUserList.onPostExecute(UserInfo.java:218)
              at android.os.AsyncTask.finish(AsyncTask.java:741)
              at android.os.AsyncTask.access$600(AsyncTask.java:197)
              at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:654)
              at android.os.Handler.dispatchMessage(Handler.java:100)
  </code></pre>
  
  <p>EDIT: This is the method call where I populate the <code>recyclerview</code>:</p>
  
  <pre><code>public void populateRecyclerList(){
      GetUserList getUserList = new GetUserList();
      getUserList.execute();
  }
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      ...
      setContentView(R.layout.usersdetails); 
      populateRecyclerList();
      }
  </code></pre>
  
  <p>This is where <code>cAdapter</code> is initialised, in <code>onCreate</code> method:</p>
  
  <pre><code>RecyclerView.Adapter cAdapter;
  ArrayList&lt;UserDetailsProvider&gt; userslist = new ArrayList&lt;UserDetailsProvider&gt;();
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      recyclerView = (RecyclerView) findViewById(R.id.recycleMusic);
      cAdapter = new UserDefinedAdapter(userslist);
      recyclerView.setAdapter(cAdapter);
      populateRecyclerList();
  }
  </code></pre>
  
  <p>EDIT: I have done something now, but the <code>populateRecyclerList()</code> is crashing in another <code>AsyncTask class</code> on <code>onPostExecute</code>. Basically, I want to repopulate the recyclerView after a user has been added. This is my code for the <code>onPostExecute()</code> method, where I am calling the <code>populateRecyclerList()</code> method:</p>
  
  <pre><code>@Override
          protected void onPostExecute(String s) {
             populateRecyclerList();
          }
  </code></pre>
  
  <p>Maybe you are not meant to call this method here? But then how would I update the <code>RecyclerView</code>?</p>