title: Updating listview isn't working
body: <p>So basically I'm collecting data from a json url in my listview. It's a chatroom type of app and in the lists I want to sync the chatroom contact lists with latest message and timestamps.</p>
  
  <p>When the json gets updated I'm calling the fuction.</p>
  
  <pre><code> public void addGroupAdapter() {
          Firebase jsonurl = new Firebase("firebase url");
          jsonurl.addValueEventListener(new ValueEventListener() {
              @Override
              public void onDataChange(DataSnapshot dataSnapshot) {
                  ContactListAdapter adapter = new ContactListAdapter(getContext(),dataSnapshot);
              try {
                  Log.i("Response Array fire",new JSONArray(dataSnapshot.getValue(String.class)).toString());
                  if (!adapted){
                      chatLists.setAdapter(adapter);
                      adapted = true;
                  }else {
                      Log.i("update",dataSnapshot.getValue(String.class));
                      adapter.setContactList(dataSnapshot);
                  }
  
              } catch (JSONException e) {
                  e.printStackTrace();
              }
              }
  
              @Override
              public void onCancelled(FirebaseError firebaseError) {
  
              }
          });
  </code></pre>
  
  <p>That Json data is stored in the firebase database . </p>
  
  <p><code>chatLists.setAdapter(adapter)</code> works well.</p>
  
  <p>But when I try to update. <code>notifyDataSetChanged();</code> doesn't work.</p>
  
  <pre><code> new ContactListAdapter(getContext(),dataSnapshot).notifyDataSetChanged();
  </code></pre>
  
  <p>I also tried invalidateviews method and same result. So where am I doing wrong?</p>
  
  <p>After reading answers I tried this. SO now this my adapter class,</p>
  
  <pre><code>class ContactListAdapter extends BaseAdapter {
          Context c;
          List lists;
          Type type = new TypeToken&lt;List&lt;ChatroomLists&gt;&gt;(){}.getType();
          JsonParser parser = new JsonParser();
          ArrayList&lt;ChatroomLists&gt; ob1 = new ArrayList&lt;ChatroomLists&gt;();
  
          public void setContactList(DataSnapshot dataSnapshot) {
              Type listType = new TypeToken&lt;ArrayList&lt;ChatroomLists&gt;&gt;() {
              }.getType();
              ob1 = new Gson().fromJson((JsonArray)parser.parse(dataSnapshot.getValue(String.class)),listType);
          Log.i("setContactList",dataSnapshot.getValue(String.class));
  
              notifyDataSetChanged();
          }
  
          ContactListAdapter(Context c, DataSnapshot group_name) {
              this.c = c;
              this.groupids = group_name;
              Type listType = new TypeToken&lt;ArrayList&lt;ChatroomLists&gt;&gt;() {
              }.getType();
              ob1 = new Gson().fromJson((JsonArray)parser.parse(group_name.getValue(String.class)),listType);
  
  
  
          }
  
  
          @Override
          public int getCount() {
  
              return ob1.size();
          }
  
          @Override
          public Object getItem(int position) {
              return position;
          }
  
          @Override
          public long getItemId(int position) {
              return position;
          }
  
          @Override
          public View getView(final int position, View convertView, ViewGroup parent) {
  
              View row = convertView;
              GroupChat.viewHolder holder = null;
  
              if (row == null) {
                  LayoutInflater inflater = (LayoutInflater) c.getSystemService (Context.LAYOUT_INFLATER_SERVICE);
                  row = inflater.inflate (R.layout.chat_list_style, parent, false);
                  holder = new GroupChat.viewHolder(row);
                  row.setTag (holder);
              } else {
                  holder = (GroupChat.viewHolder) row.getTag ();
  
              }
  
              ChatroomLists chatroomLists =  ob1.get(position);
              Iterator&lt;ChatroomLists&gt; iter = ob1.iterator();
              String id = chatroomLists.getId();
              String time = chatroomLists.getTimestamp();
              Log.i("updated data",id + time);
  
              viewHolder finalHolder = holder;
              Firebase chatlink = new Firebase ("firebase link");
              chatlink.addValueEventListener(new ValueEventListener() {
                  @Override
                  public void onDataChange(DataSnapshot dataSnapshot) {
                      for (DataSnapshot d: dataSnapshot.getChildren()){
                          finalHolder.user_message.setText (dataSnapshot.child(d.getKey()).child("message").getValue(String.class));
  
                      }
                  }
  
                  @Override
                  public void onCancelled(FirebaseError firebaseError) {
  
                  }
              });
  
  
              Firebase imageurl = new Firebase("firebase link");
              imageurl.addValueEventListener(new ValueEventListener() {
                  @Override
                  public void onDataChange(DataSnapshot dataSnapshot) {
                      Glide.with (getActivity ())
                              .load (dataSnapshot.getValue(String.class))
                              .error (R.drawable.man)
                              .into (finalHolder.user_img);
                  }
  
                  @Override
                  public void onCancelled(FirebaseError firebaseError) {
  
                  }
              });
  
              holder.user_name.setText (id);
  
              row.setOnClickListener (new View.OnClickListener () {
                  @Override
                  public void onClick(View v) {
                      Intent intent = new Intent (getActivity (), ChatRoom.class);
                      intent.putExtra ("group_name", id);
                      startActivity (intent);
                  }
              });
              registerForContextMenu (row);
              return row;
          }
      }
  </code></pre>
  
  <p>But it's still not updating.. :(</p>
  
  <p>UPDATE: <strong>Listview was so buggy in this case. And I changed to Recyclerview. Now everything is working smoothly.</strong></p>