Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 7th, 2012  |  syntax: None  |  size: 0.56 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Downloading files into a folder inside android application
  2. directory = new File (Environment.getExternalStorageDirectory().toString()  +"/data/"+getPackageName()+"/files");
  3.  
  4. directory.mkdirs();
  5.  
  6.  
  7. if(DeleteFlag!=1 || !downloadTask.isCancelled()){
  8.  
  9. file1 = new File(directory, audioFileName);
  10.  
  11. output = new FileOutputStream(file1);
  12.  
  13. byte data[] = new byte[1024];
  14.  
  15. long total = 0;
  16.  
  17.     while ((count = input.read(data)) != -1) {
  18.         total += count;
  19.         publishProgress(""+(int)((total*100)/lenghtOfFile));
  20.         output.write(data, 0, count);
  21.     }
  22.     }