@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"; } }
private String[][] parseData(String JsonString) throws JSONException { int k = 1; String[] urlAdress; Gson gson = new Gson(); SearchResponse response = gson.fromJson(JsonString, SearchResponse.class); List<Result> results = response.root; dataSayisi = results.size() + 1; values = new String[dataSayisi][6]; values[0][0] = this.categoryName; for (Result result : results) { values[k][0] = result.ContentType; values[k][1] = result.ID; values[k][2] = result.CategoryID; values[k][3] = result.Category; values[k][4] = result.Title; urlAdress = result.ImageURL.split("/"); values[k][5] = urlAdress[urlAdress.length - 1]; k++; } return values; }