1. Are you ready for the Galaxy S20? Here is everything we know so far!

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

Discussion in 'Android Development' started by Thomas Thorton, Dec 11, 2021.

  1. Thomas Thorton

    Thread Starter

    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?
     



    1. Download the Forums for Android™ app!


      Download

       
Loading...

Share This Page

Loading...