کلیدستان

نسخه‌ی کامل: به شدت به کمکتون نیاز دارم لطفا
شما در حال مشاهده نسخه آرشیو هستید. برای مشاهده نسخه کامل کلیک کنید.
سلام دوستان عزیز چطور می تونم این کار ها رو برای این کد انجام بدم
  1. Create an AsyncTask File

  2. Connect to the server Using httpGet or Post

  3. Store the Response to the data/data/packagename/mydownload`
کد پی‌اچ‌پی:
fileName fileName.replaceAll("[^a-zA-Z0-9- _,()]+","")+ ".(your format example PDF)";

 
   client = new DefaultHttpClient();

 
       request = new HttpGet(URL);



 
   response client.execute(request);



 
   HttpEntity entity response.getEntity();
 
   String PATH "/data/data/" context.getPackageName() + "/mydownload/";
 
   File file = new File(PATH);
 
   file.mkdirs();



 
   final long lenghtOfFile entity.getContentLength();
 
   File outputFile = new File(filefileName);

 
   Log.i("length",lenghtOfFile +fileName);
 
   //if(outputFile.exists())   {
 
   FileOutputStream fos = new FileOutputStream(outputFile);

 
   InputStream  is entity.getContent();



 
   byte[] buffer = new byte[1024];
 
   int len1 0;
 
   long total 0;


 
   while ((len1 is.read(buffer)) != -1) {
 
       fos.write(buffer0len1); 

 
       }

 
   }
 
   fos.close();
 
   is.close(); 
Heart Idea Iran