update listview automatically when a new data is entered in the database [closed]

1

I created a webservice and the application and everything worked fine, however I would like my app to update the listview as soon as a new data is entered in the database (this data may come from another device) and I would like you to send a notification too , but my problem is in updating the listview, I think I should create an AsyncTask or a Service, however, I've read about them but I'm having a hard time understanding them and using them, so is there any other way to do this list update without the use of AsyncTask or Service, if not, does anyone have a good example to pass me?

I have an application that shows me the tasks I should do today, and this information is stored in a database that access through a webservice, however when a new task is inserted into the database I have to go in application and click the button to refresh the listview and thus the new task appears.

I would like when the new task was inserted into the database, my app on my phone would update the listview automatically and display a notification or play an audio or vibrate the phone and etc ...

    
asked by anonymous 06.07.2017 / 14:10

1 answer

0

You can create a ContentProvider in your app to access / manipulate database data (in lieu of queries directly to the base) and implement a CursorLoader in your Activity (which will get the data through the ContentProvider) and change the adapter of your ListView to use the data of that cursor returned by the Loader. With this, ListView will always be updated because a listener for the bank is automatically created in this implementation.

It's complicated to detail all the steps here, as there are several, so I suggest you take a look at this course that explains perfectly well how to implement this:

link

    
06.07.2017 / 16:40