Thomas Thorton
Lurker
Is it possible to update JSON API when new data is added to the JSON? I tried to use Handler but the problem is that when I run the application the data is duplicated and they are shown up in the recyclerView more and more times as it runs. Here is what I did:
So, what I want is every time the handler refreshes to be added only the new data and not to duplicate the whole data every time it is refreshed. Is there a way to do that?
- handler.postDelayed( runnable = new Runnable() {
- public void run() {
- //do your function;
- ReadPosts();
- readSaves();
- postsAdapter.notifyDataSetChanged();
- postsAdapterS.notifyDataSetChanged();
- handler.postDelayed(runnable, apiDelayed);
- }
- }, apiDelayed);
So, what I want is every time the handler refreshes to be added only the new data and not to duplicate the whole data every time it is refreshed. Is there a way to do that?