title: Attempt to invoke Adapter.notifyDataSetChanged()' on a null object refernce
body: <p>I have tried adding the adapter in the onCreate() as well and it throws a null pointer exception with an error 'Attempt to invoke listVIew.setAdapter on a null object reference.</p>
  
  <p>Here is the code where I use notifyDataSetChange() inside my Main Activity;</p>
  
  <pre><code>import static com.name.sample.Tab1.adapter;
  
  
  public class Requests extends AsyncTask&lt;String, Void, String&gt; {
  
      @Override
      protected String doInBackground(String... params) {
  
          Cursor c =  myDB.rawQuery("SELECT * FROM requests", null);
  
          int aIndex = c.getColumnIndex("name");
          int bIndex = c.getColumnIndex("nick");
          int cIndex = c.getColumnIndex("num");
  
          name.clear();
          nick.clear();
          number.clear();
  
          if (c.moveToFirst()){
  
              do {
  
                  name.add(c.getString(aIndex));
                  nick.add(c.getString(bIndex));
                  number.add(c.getInt(cIndex));
  
              } while (c.moveToNext());
          }
  
          return null;
      }
  
      @Override
      protected void onPostExecute(String s) {
          super.onPostExecute(s);
  
  
          adapter.notifyDataSetChanged();
  
  
      }
  }
  </code></pre>
  
  <p>Here is my Tab1 code
  Here is the code for the Adapter</p>
  
  <pre><code>public class Tab1 extends Fragment {
  
  static ListView listNotifications;
  final static ArrayList&lt;String&gt; name = new ArrayList&lt;&gt;();
  static ArrayList&lt;Integer&gt; number = new ArrayList&lt;&gt;();
  static ArrayList&lt;String&gt; nick = new ArrayList&lt;&gt;();
  
  static ImageAdapter adapter;
  
  
  public static class ImageAdapter extends ArrayAdapter&lt;String&gt; {
      private final Context context;
      private final String[] values;
  
      public ImageAdapter (Context context, String[] values) {
          super(context, R.layout.list_with_icons, values);
          this.context = context;
          this.values = values;
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
  
          LayoutInflater inflater = (LayoutInflater) context
                  .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  
          View rowView = inflater.inflate(R.layout.list_with_icons, parent, false);
  
          TextView textView = (TextView) rowView.findViewById(R.id.textViewName);
  
          ImageView imageView = (ImageView) rowView.findViewById(R.id.imagePicture);
  
          textView.setText(values[position]);
          // Change the icon for Windows and iPhone
  
  
          return rowView;
      }
  }
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
  
      View rootView = inflater.inflate(R.layout.tab1layout, container, false);
  
      String[] nameString = new String[name.size()];
      nameString = name.toArray(nameString);
  
      adapter = new ImageAdapter (getActivity(), nameString);
  
  
  
     listNotifications =(ListView)rootView.findViewById(R.id.listNotifications);
  
  listNotifications.setAdapter(adapter);
  
  
  
  
      return rootView;
  
  
  }}
  </code></pre>