How to clear data from JSONArray
there is nothing like it:
jsonArray.clear();
:
jsonArray.remove(index);
which was suggested here:
How to remove a specific item from a JSONArray?
thanks
jsonArray = new JSONArray(new ArrayList<String>());
this is not a perfect answer, but you can do it,
jsonArray=new jsonArray("[{}]");
Newly made local variables
JSONArray jsonArray = new JSONArray(); jsonArray.put(productlist);
Every time jsonserver data is added using local block, if u declear is global block then jsonarray needs to be cleared
In the library I have, there is no way to call clear() private ArrayList inside a JSONObject . However, it has public Object remove(int index) . I just use new JSONObject() : (
clear()
ArrayList
JSONObject
public Object remove(int index)
new JSONObject()
I try everything, but the only thing that worked for me was
JSONarray=null;
this is one answer try:
jsonArray=[]