java – Deleting JSONArray Element


In my Android app comes JSONArray . It looks something like this:


Under certain circumstances, I have to delete one of the array elements. Now I do it like this:


But the remove method works starting from API 19. I need to do it at 17. How can I remove an element so that API 17 also understands what's what?


If you do not need to leave a link to the original array and it is permissible to create a new one, then like this:

public static JSONArray remove(final JSONArray from, final int index) throws JSONException {
    final JSONArray res = new JSONArray();
    for (int i = 0, count = from.length(); i < count; i++) {
        if(index != i)

    return res;
Scroll to Top