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

aakarshrestha
aakarshrestha
6,509 Points

Refresh the foreground and show the new data when the data is inserted in the mysql database.

How do i get the newly inserted data in my activity from the database without refreshing the activity?

For example, User1 sends out the text to user2. When user1 sends out the text, it is inserted into the database. But user2 does not know that there is a new message for him unless user2 refresh the activity.

Any help is appreciated!

Happy Coding!

1 Answer

Probably something like an event bus which listens out for events. Check out Otto event bus.