Reputation: 93
I am building and android application and using pull down referees. I wanna to clear the old jsonArray data and reload the new data that coming from server.
I have tried many thinking like - JsonArray test = new JsonArray(), JsonArray test("[]");
but nothing is working can some one help me in solving this.
Upvotes: 2
Views: 1320
Reputation: 27
You need to run a while loop across the length of the test and at each time delete the first index. the loop will reach a stage when the length of the test is zero to show the test is not empty and and cleared.
while (test.length() > 0) {
test.remove(0)
}
Upvotes: 1
Reputation: 3922
Try this for clearing JSONArray:
jsonArray = new JSONArray(new ArrayList<String>());
Upvotes: 2