Insert imagepath dymanically
<p>I'm trying to get the images in grid view using universalimageloader from <a href="https://github.com/nostra13/Android-Universal-Image-Loader" rel="nofollow">github</a>. But instead of loading a static final image from constant, I want to load the image path dynamically from server. So I made a jsonparser to load information from server and parse it. But I'm struggling to assign this to IMAGES string array. Please suggest me how to assign. I'm newbie to android.</p>

<p>ImageConstants.java</p>

<pre><code>import java.util.ArrayList;
import java.util.HashMap;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.app.ProgressDialog;
import android.os.AsyncTask;
import android.util.Log;

public class ImageConstant {

    public static String[] IMAGE1;
    private static String[] constants;
    public static String url = "http://ensign119.com/assets/image11.php";

        // JSON Node names
        protected static final String TAG_PRODUCTS = "image_path";
        protected static final String TAG_CID = "file_id";
        public static final String TAG_NAME = "file_name";

        // contacts JSONArray  
        JSONArray products = null;

    public String[] ImageConstant() {
        // TODO Auto-generated constructor stub

        new Message().execute(url);
        for(int i=0; i&lt;IMAGE1.length;i++){
            constants[i] = IMAGE1[i];
        }

        for(String name:constants){
            Log.d("new path", name);
        }

        return constants;
    }

    class Message extends AsyncTask&lt;String, Integer, ArrayList&lt;HashMap&lt;String, String&gt;&gt; &gt; {
        ArrayList&lt;HashMap&lt;String, String&gt;&gt; mylist = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
//      ProgressDialog progress = new ProgressDialog(Path.this);
        // Creating JSON Parser instance
        JSONParser jParser = new JSONParser();
                @Override
            protected ArrayList&lt;HashMap&lt;String, String&gt;&gt; doInBackground(String... params) {

                    Log.d("doInBackgound","backgound is running");

                    Log.d("json string ", jParser.getJSONFromUrl(url).toString());
                    // getting JSON string from URL
                    JSONObject json = jParser.getJSONFromUrl(url);

                    Log.d("path_parsing", "before parsing");
                    try {
                        // Getting Array of Contacts
                        products = json.getJSONArray(TAG_PRODUCTS);

                        // looping through All Contacts
                        for(int i = products.length()-1; i &gt;=0; i--){
                            JSONObject c = products.getJSONObject(i);

                            // Storing each json item in variable
                            String cid = c.getString(TAG_CID).toString();
                            String name = c.getString(TAG_NAME);
                            // creating new HashMap
                            HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();

                            // adding each child node to HashMap key =&gt; value
                            map.put(TAG_CID, cid);
                            map.put(TAG_NAME, name);

                            // adding HashList to ArrayList
                            mylist.add(map);
                            Log.d("mylist_value", mylist.toString());
                        }
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                    Log.d("path_parsing", "after parsing");   
                    return mylist;

                }

            @Override
            protected void onPostExecute(ArrayList&lt;HashMap&lt;String, String&gt;&gt; result) {
//              if(progress.isShowing()){
//                  progress.dismiss();
//              }
                IMAGE1 = new String[result.size()];
                for(int i=0; i&lt;result.size(); i++){
                   IMAGE1[i] = result.get(i).get("file_name");
                }
                for(String path: IMAGE1){
                    Log.d("path", path.toString());
                }
                Log.d("postExecute","Postexecute is running");
            }

            @Override
            protected void onProgressUpdate(Integer... values) {
                // TODO Auto-generated method stub
                super.onProgressUpdate(values);

            }

            @Override
            protected void onPreExecute() {
                // TODO Auto-generated method stub
            }
    }

}
</code></pre>

<p>Constants.java</p>

<pre><code>public final class Constants {

    public static final String[] IMAGES = new String[] {

            "http://wrong.site.com/corruptedLink", // Wrong link
    };

    private Constants() {
    }

    public static class Config {
        public static final boolean DEVELOPER_MODE = false;
    }

    public static class Extra {
        public static final String IMAGES = "com.nostra13.example.universalimageloader.IMAGES";
        public static final String IMAGE_POSITION = "com.nostra13.example.universalimageloader.IMAGE_POSITION";
    }
}
</code></pre>
