0

i'm new in android development(sorry for my english i'm french). I want to create a chat app. Now I have a listview based on local database.

Also I have a broadcast receiver which check if the connection changed. When the connection changed and is ok it update the local Database. But i want that if the app is running that the list of message refresh.

How can I do that? My list is linked with my local DB with a custom cursor adapter.

Ananta
  • 660
  • 1
  • 7
  • 19

1 Answers1

0

The easiest way is to use another intent and a broadcast receiver to notify every component of your app that the database has been updated. Instead of the Android components (intent + broadcast receiver) you can also use some event bus library like Otto to make the things easier.

Your activity subscribes to some business class in the onCreate method and unsubscribes from it in the onDestroy, so it always get notified from the changes when it is running.

droidpl
  • 5,872
  • 4
  • 35
  • 47