title: How to JSON parse images from mysql and populate listview
body: <p>Hey guys i am trying to populate a listview with images from database. I have uploaded my images to the server and took the full path like <a href="http://www.spinner.bl.ee/images/ATE.png" rel="nofollow">http://www.spinner.bl.ee/images/ATE.png</a> and stored it as a varchar in a database column named image. then i have a .php file which you can see here <a href="http://spinner.bl.ee/getstocks.php" rel="nofollow">http://spinner.bl.ee/getstocks.php</a> that gives me a json array named metoxes with all the data. but the image is a bit different(meaning the path) how can i fix that??</p>
  
  <p>In my java file in android app in the imageview i get the full path instead of the image. any help will be highly appreciated!</p>
  
  <p>My code</p>
  
  <pre><code>private class JsonReadTask extends AsyncTask&lt;String, Void, String&gt; {
          @Override
          protected void onPreExecute() {
              super.onPreExecute();
              pDialog = new ProgressDialog(MainActivity.this);
              pDialog.setTitle(R.string.waiting);
              pDialog.setMessage(getString(R.string.get_stocks));
              pDialog.setCancelable(false);
              pDialog.show();
          }
  
          @Override
          protected String doInBackground(String... params) {
  
              HttpClient httpclient = new DefaultHttpClient();
              HttpPost httppost = new HttpPost(params[0]);
              try {
                  HttpResponse response = httpclient.execute(httppost);
                  jsonResult = inputStreamToString(
                          response.getEntity().getContent()).toString();
              }
  
              catch (ClientProtocolException e) {
                  e.printStackTrace();
              } catch (IOException e) {
                  e.printStackTrace();
              }
              return null;
          }
  
          private StringBuilder inputStreamToString(InputStream is) {
              String rLine = "";
              StringBuilder answer = new StringBuilder();
              BufferedReader rd = new BufferedReader(new InputStreamReader(is));
  
              try {
                  while ((rLine = rd.readLine()) != null) {
                      answer.append(rLine);
                  }
              }
  
              catch (IOException e) {
                  // e.printStackTrace();
                  Toast.makeText(getApplicationContext(),
                          "Error..." + e.toString(), Toast.LENGTH_LONG).show();
              }
              return answer;
          }
  
          @Override
          protected void onPostExecute(String result) {
  
              ListDrwaer();
              pDialog.dismiss();
          }
  
      }// end async task
  
      public void accessWebService() {
          JsonReadTask task = new JsonReadTask();
          // passes values for the urls string array
          task.execute(new String[] { url });
      }
  
      // build hash set for list view
      public void ListDrwaer() {
          List&lt;Map&lt;String, String&gt;&gt; stocksList = new ArrayList&lt;Map&lt;String, String&gt;&gt;();
  
          try {
              JSONObject jsonResponse = new JSONObject(jsonResult);
              JSONArray jsonMainNode = jsonResponse.optJSONArray("metoxes");
              for (int i = 0; i &lt; jsonMainNode.length(); i++) {
                  JSONObject jsonChildNode = jsonMainNode.getJSONObject(i);
                  String name = jsonChildNode.optString("name");
                  String price = jsonChildNode.optString("price");
                  String image = jsonChildNode.getString("image");
                  //Log.i("image is valid", image);
                  //String outPut =  name + price;
                  //BitmapFactory.decodeFile(image);
                  stocksList.add(createStockList(name, price, image));
              }
  
  
          } catch (JSONException e) {
              Toast.makeText(getApplicationContext(), "Error" + e.toString(),
                      Toast.LENGTH_SHORT).show();
          }
          //byte[] image = {};
          String[] from = { "name", "price", "image" };
          //BitmapFactory.decodeByteArray(image, 50, image.length);
          int[] to = { R.id.stock_name, R.id.stock_price, R.id.dbImage };
          SimpleAdapter simpleAdapter = new SimpleAdapter(this, stocksList,
                  R.layout.list_item,
                  from, to);
          listView.setAdapter(simpleAdapter);
      }
  
      private HashMap&lt;String, String&gt; createStockList(String name, String price, String image) {
          HashMap&lt;String, String&gt; stockNameNo = new HashMap&lt;String, String&gt;();
          stockNameNo.put("name", name);
          stockNameNo.put("price", price);
          stockNameNo.put("image", image);
          return stockNameNo;
      }
  }
  </code></pre>
  
  <p>Thanks in advance.</p>