@Override protected String doInBackground(String... arg0) { File dir = new File(this.dirName); if (dir.isDirectory()) { String[] children = dir.list(); for (int i = 0; i < children.length; i++) { new File(dir, children[i]).delete(); } } String urlAdress = this.pathName; String jString = null; try { File root = new File("/sdcard/Vatan"); root.mkdir(); File directory = new File(this.dirName); directory.mkdir(); URL url; url = new URL(urlAdress); URLConnection ucon = url.openConnection(); InputStream is = ucon.getInputStream(); BufferedInputStream bis = new BufferedInputStream(is); ByteArrayBuffer baf = new ByteArrayBuffer(50); int current = 0; while ((current = bis.read()) != -1) { baf.append((byte) current); } jString = new String(baf.toByteArray()); Gson gson = new Gson(); SearchResponse response = gson.fromJson(jString, SearchResponse.class); List<Result> results = response.root; String[] urlAdress1 = null; for (Result result : results) { // values[0][0][0]=result.ImageURL; if (!result.ImageURL.equals("")) { urlAdress1 = result.ImageURL.split("/"); Global.DownloadFile( Global.resizeImageURL(result.ImageURL, "133", "0"), urlAdress1[urlAdress1.length - 1], this.dirName); } } return jString; } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); return "hata1"; } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); return "hata1"; } }