May 21, 2021
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:

  1. handler.postDelayed( runnable = new Runnable() {
  2. public void run() {
  3. //do your function;
  4. ReadPosts();
  5. readSaves();
  6. postsAdapter.notifyDataSetChanged();
  7. postsAdapterS.notifyDataSetChanged();
  8. handler.postDelayed(runnable, apiDelayed);
  9. }
  10. }, 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?