Android - What does adapter.notifyDataSetInvalidated do?

Tawani picture Tawani · Jul 10, 2010 · Viewed 25.3k times · Source

What does the method adapter.notifyDataSetInvalidated() accomplish? There is no documentation on it.

I am trying to reload a ListView and notifyDataSetChanged or notifyDataSetInvalidated don't seem to accomplish anything.

Answer

lucidd picture lucidd · Jul 10, 2010

As far as I know, the notifyDataSetInvalidated() method stops the adapter from accessing the data (in case it's invalid, unavailable, etc.). The notifyDataSetChanged() method updates the ListView so you can see the new data added, but you have to call it in the UI thread.

It helped me a lot to watch this video -- there are two sections where they mention those methods and explain how to use them correctly. Maybe it helps you too :)