Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.20 KB | None | 0 0
  1.  
  2. public class download_applegaramound {
  3.  
  4.         public void download_applegaramound() {
  5.  
  6.             final ProgressDialog dialog = ProgressDialog.show(this, "TitleMessage", true);
  7.             final Handler handler = new Handler() {
  8.                 public void handleMessage(Message msg) {
  9.                     dialog.dismiss();
  10.                 }
  11.             };
  12.  
  13.                     Thread checkUpdate = new Thread() {  
  14.                        public void run() {
  15.                             try {
  16.                                   byte[] b = new byte[1];
  17.                                   URL url = new URL("");
  18.                                   URLConnection urlConnection = url.openConnection();
  19.                                   urlConnection.connect();
  20.                                   DataInputStream di = new DataInputStream(urlConnection.getInputStream());
  21.                                   FileOutputStream fo = new FileOutputStream("/sdcard/");
  22.                                   while (-1 != di.read(b, 0, 1))
  23.                                     fo.write(b, 0, 1);
  24.                                   di.close();
  25.                                         fo.close();
  26.                               } catch (IOException e) {
  27.                                 // TODO Auto-generated catch block
  28.                                 e.printStackTrace();
  29.                                
  30.                               }
  31.                                  handler.sendEmptyMessage(0);
  32.                           }
  33.                        };
  34.                     checkUpdate.start();
  35.         }
  36.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement