66

What is the difference? The android documentation doesn't have a description for notifyDataSetInvalidated(). I was thinking maybe you call that function to notify all registered listeners, but use notifyDataSetChanged() to not notify them?

Spidy
  • 38,131
  • 15
  • 59
  • 77

1 Answers1

84

Changed means the data set changed. Individual items updated, or items were added or removed. Invalidated means the data source is no longer available.

adamp
  • 28,362
  • 8
  • 79
  • 68
  • 25
    To expand on this, a response from Romain Guy: "notifyDataSetInvalidated() means that the data inside the adapter is no longer valid. This will cause ListView to stop populating. There should seldom be any reason to use it." – Glendon Trullinger Jun 17 '11 at 00:25
  • 2
    To further explain @Glendon's comment, [this Google groups thread](https://groups.google.com/d/topic/android-developers/1tsRQczqbt0/discussion) and [this one](https://groups.google.com/d/topic/android-developers/WJshF8aZeUY/discussion) contained similar questions that were answered by an Android framework engineer named Romain Guy. – Jeff Axelrod Jun 22 '11 at 14:49
  • 6
    If anyone is interested in what happens programmatically behind the scenes when calling these methods, see my answer [here](http://stackoverflow.com/questions/3219779/android-what-does-adapter-notifydatasetinvalidated-do/7734032#7734032) – Tony Chan Oct 12 '11 at 00:28
  • The documentation for these methods has been expanded for an upcoming release. – adamp Oct 12 '11 at 04:39