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:

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?

原文链接:How can I update JSON API items when a new item is added?

© 版权声明
THE END
喜欢就支持一下吧
点赞15 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容