title: How to update ArrayAdapter in Fragment using AsyncTaskLoader?
body: <p>I'm setting up a Fragment(TabLayout) and an ArrayAdapter for to display the list of words.
  I want to update the Fragment after the data is completely fetched from source which is returned in onLoadFinished(). The AsyncTaskLoader is set in the MainActivity.</p>
  
  <pre><code>@Override
  public void onLoadFinished(Loader&lt;List&lt;Word&gt;&gt; loader, List&lt;Word&gt; words) {
  
              if (words != null &amp;&amp; !words.isEmpty()) {
          NounsFragment nounsFragment = new NounsFragment();
          nounsFragment.updateList(words);
  
          NumberFragment numberFragment = new NumberFragment();
          numberFragment.updateList(words);
  
          Log.v(LOG_TAG, "OnFinishedLoad status : " + words.size());
      }else{
          Toast.makeText(this, R.string.no_words, Toast.LENGTH_SHORT).show();
      }
  }
  </code></pre>
  
  <p>Then I call the function in my fragment updateList() to update the fragent.</p>
  
  <pre><code> public void updateList(List&lt;Word&gt; words) {
  
      // Hide loading indicator because the data has been loaded
      //View loadingIndicator = rootView.findViewById(R.id.loading_indicator);
      //loadingIndicator.setVisibility(View.GONE);
  
      //TextView loadingTextView = rootView.findViewById(R.id.loading_text_view);
      //loadingTextView.setVisibility(View.GONE);
  
      mAdapter.clear();
  
      if (words != null &amp;&amp; !words.isEmpty()) {
          List&lt;Word&gt; wordsList = new ArrayList&lt;&gt;();
  
          for (int i = 0; i &lt; words.size(); i++) {
              Word word = words.get(i);
              Log.v(LOG_TAG, "Current Word Category: " + word.getmCategory());
              if (word.getmCategory() != null) {
                  if (word.getmCategory().contains("1"))
                      wordsList.add(word);
                  Log.v(LOG_TAG, "Item Added: " + word.getmEnglishTranslation());
              }
          }
          //words.add(new Word("Uhr", "Clock", 2));
          //words.add(new Word("Bleistift","Pencil", 1 ));
          mAdapter.addAll(wordsList);
      } else {
  
          // Set empty state text to display "No earthquakes found."
          mEmptyStateTextView.setText(R.string.no_words);
          Toast.makeText(getActivity(), R.string.no_words, Toast.LENGTH_SHORT).show();
      }
  }
  </code></pre>
  
  <p>I'm getting runtime error </p>
  
  <pre><code> FATAL EXCEPTION: main
  Process: com.example.android.german, PID: 24298
                                                                          java.lang.NullPointerException: Attempt to invoke virtual method 'void com.example.android.german.WordAdapter.clear()' on a null object reference
  at com.example.android.german.NounsFragment.updateList(NounsFragment.java:63)
                                                                              at com.example.android.german.MainActivity.onLoadFinished(MainActivity.java:83)
                                                                              at com.example.android.german.MainActivity.onLoadFinished(MainActivity.java:22)
                                                                              at android.app.LoaderManagerImpl$LoaderInfo.callOnLoadFinished(LoaderManager.java:483)
                                                                              at android.app.LoaderManagerImpl$LoaderInfo.onLoadComplete(LoaderManager.java:451)
                                                                              at android.content.Loader.deliverResult(Loader.java:144)
                                                                              at android.content.AsyncTaskLoader.dispatchOnLoadComplete(AsyncTaskLoader.java:265)
                                                                              at android.content.AsyncTaskLoader$LoadTask.onPostExecute(AsyncTaskLoader.java:92)
                                                                              at android.os.AsyncTask.finish(AsyncTask.java:651)
                                                                              at android.os.AsyncTask.-wrap1(AsyncTask.java)
                                                                              at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:668)
                                                                              at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                              at android.os.Looper.loop(Looper.java:148)
                                                                              at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                              at java.lang.reflect.Method.invoke(Native Method)
                                                                              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
  </code></pre>