Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Android Data Persistence CRUD Operations with SQLite Deleting Data

Raghda Talaa't
Raghda Talaa't
2,944 Points

Should i use this "refreshMemes()" instead of this "mMemeItemListAdapter.notifyDataSetChanged()" ?

In the Starter files --> MemeItemFragment

There was this line ( should be at L75):

mMemeItemListAdapter.notifyDataSetChanged();

But in the video it's not showing, I commented it and used refreshMemes() like the video and it worked.

Does it mean anything?!

1 Answer

Ratul Sarna
PLUS
Ratul Sarna
Courses Plus Student 11,618 Points

This question is quite old and you might have the answer now, but here's my 2 cents.

We don't need to notify the adapter that the DataSet has changed because we are resetting the ListAdapter alltogether in the refreshMemes() method. So the list will be updated once the Meme is deleted. That is why it works fine.

Harry James
Harry James
14,780 Points

I'm going to mark this as the Best Answer since the post author hasn't been active on this topic for a long time and an answer hasn't been chosen.

Your answer here is indeed correct and the code isn't needed :)

Binyamin Friedman
Binyamin Friedman
14,615 Points

I know this post isn't active, but I still wanted to point this out. If you use the notifyDataSetChanged(), then you will get a NullPointerException because that variable is never set or used. It must have been an error when they were making the project files.