Code example for JSONArray

Methods: length, optString

0
     * @param defaultString the default to be used if the arg does not exist 
     * @return String with the retrieved value 
     */ 
    private static String getArgument(JSONArray args, int position, String defaultString) {
        String arg = defaultString;
        if (args.length() > position) {
            arg = args.optString(position);
            if (arg == null || "null".equals(arg)) {
                arg = defaultString;
            } 
        } 
        return arg;
    } 
 
    /** 
     * Downloads a file form a given URL and saves it to the specified directory. 
     * 
     * @param source        URL of the server to receive the file 
     * @param target      	Full path of the file on the file system 
     */ 
    private void download(final String source, final String target, JSONArray args, CallbackContext callbackContext) throws JSONException {