• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps How can I update JSON API items when a new item is added?

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?
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones