title: Parse json data and get image in android
body: <p>Here, I've to get image from json data and have to set that image in image view. I have got all the other necessary data from json and set them to text view, but could not set the image to image view. Below is my code,</p>
  
  <h2>MainActivity.java</h2>
  
  <pre><code>public class MainActivity extends ListActivity {
      private Context context;
  
      // this url returns json encoded data
      private static String url = "http://192.168.0.104/productdetails/product.php";
  
      private static final String NAME = "name";
      private static final String STORE_NAME = "store_name";
      private static final String PIC = "pic";
      //private static final String TREAD = "Tread";
  
      ArrayList&lt;HashMap&lt;String, String&gt;&gt; jsonlist = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
  
      ListView lv ;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          new ProgressTask(MainActivity.this).execute();
      }
  
      private class ProgressTask extends AsyncTask&lt;String, Void, Boolean&gt; {
          private ProgressDialog dialog;
  
          private ListActivity activity;
  
          // private List&lt;Message&gt; messages;
          public ProgressTask(ListActivity activity) {
              this.activity = activity;
              context = activity;
              dialog = new ProgressDialog(context);
          }
  
          private Context context;
  
          protected void onPreExecute() {
              this.dialog.setMessage("Please wait...");
              this.dialog.show();
          }
  
          @Override
          protected void onPostExecute(final Boolean success) {
              if (dialog.isShowing()) {
                  dialog.dismiss();
              }
              ListAdapter adapter = new SimpleAdapter(context, jsonlist,
                      R.layout.list_item, new String[] { NAME, STORE_NAME, PIC,
                               }, new int[] {
                              R.id.vehicleType, R.id.vehicleColor, R.id.image });
  
              setListAdapter(adapter);
              lv = getListView();
          }
  
          protected Boolean doInBackground(final String... args) {
  
              JSONParser jParser = new JSONParser();
  
              // get JSON data from URL
              JSONArray json = jParser.getJSONFromUrl(url);
  
              for (int i = 0; i &lt; json.length(); i++) {
  
                  try 
                  {
                      JSONObject c = json.getJSONObject(i);
                      String name = c.getString(NAME);
  
                      String storename = c.getString(STORE_NAME);
                      String pic = c.getString(PIC);
  
  
                      HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
  
                      // Add child node to HashMap key &amp; value
                      map.put(NAME, name);
                      map.put(STORE_NAME, storename);
                      map.put(PIC, pic);
  
                      jsonlist.add(map);
                  }
                  catch (JSONException e) {
                      e.printStackTrace();
                  }
              }
              return null;
          }
      }
  }
  </code></pre>
  
  <h2>JSONParser.java</h2>
  
  <pre><code>public class JSONParser {
  
      static InputStream iStream = null;
      static JSONArray jarray = null;
      static String json = "";
  
      public JSONParser() {
      }
  
      public JSONArray getJSONFromUrl(String url)
      {
  
          StringBuilder builder = new StringBuilder();
          HttpClient client = new DefaultHttpClient();
          HttpGet httpGet = new HttpGet(url);
  
          try 
          {
              HttpResponse response = client.execute(httpGet);
              StatusLine statusLine = response.getStatusLine();
              int statusCode = statusLine.getStatusCode();
  
              if (statusCode == 200) 
              {
                  HttpEntity entity = response.getEntity();
                  InputStream content = entity.getContent();
                  BufferedReader reader = new BufferedReader(new InputStreamReader(content));
                  String line;
                  while ((line = reader.readLine()) != null) 
                  {
                      builder.append(line);
                  }
              } 
  
              else 
              {
                  Log.e("==&gt;", "Failed to download file");
              }
          }
  
          catch (ClientProtocolException e) 
          {
              e.printStackTrace();
          }
  
          catch (IOException e) 
          {
              e.printStackTrace();
          }
  
          // Parse String to JSON object
          try
          {
              jarray = new JSONArray(builder.toString());
          } 
  
          catch (JSONException e) 
          {
              Log.e("JSON Parser", "Error parsing data " + e.toString());
          }
  
          // return JSON Object
          return jarray;
  
      }
  }
  </code></pre>
  
  <p>How to decode image and show in image view?</p>