将URL添加到图像名称

I am retrieving JSON objects from a PHP file to my Android app. One of the objects attributes is an image file name. All images are hosted on a web folder.

At this moment, the object attribute is the image file name, but I need the complete URL to the file to be able to display the image on the app.

What should I do to obtain a better performance:

  1. Add the URL string to the file name at the PHP file prior to execute the JSONencode function?
  2. Add the URL string to the file name at the app code after receiving the JSON array from the web server?

This is the piece of code I am using to retrieve the JSON array:

protected Void doInBackground(Void... params) {
            // Create an array
            arraylist = new ArrayList<HashMap<String, String>>();
            // Retrieve JSON Objects from the given URL address
            jsonobject = JSONfunctions
                    .getJSONfromURL("http://.../android_ofertaslist_todas.php");

            try {
                // Locate the array name in JSON
                jsonarray = jsonobject.getJSONArray("Categorias");

                for (int i = 0; i < jsonarray.length(); i++) {
                    HashMap<String, String> map = new HashMap<String, String>();
                    jsonobject = jsonarray.getJSONObject(i);
                    // Retrive JSON Objects
                    map.put("valoracionEmpresa", jsonobject.getString("valoracionEmpresa"));
                    map.put("nombreEmpresa", jsonobject.getString("nombreEmpresa"));
                    map.put("direccionEmpresa", jsonobject.getString("direccionEmpresa"));
                    map.put("strImagen", jsonobject.getString("strImagen"));//<--- THIS IS THE IMAGE FILE NAME
                    // Set the JSON Objects into the array
                    arraylist.add(map);
                }
            } catch (JSONException e) {
                Log.e("Error", e.getMessage());
                e.printStackTrace();
            }
            return null;
        }

both ways will result same performance:

  1. Add the URL string to the file name at the PHP file prior to execute the JSONencode function?
  2. Add the URL string to the file name at the app code after receiving the JSON array from the web server?

better way is add url string at server side and retrieve absolute path of image in json, so that in future you can change the location of your images and url on server without doing any change at your mobile app code.