1

このコードを使用して URL からダウンロードしています。Android 4 ではうまく動作しますが、Android 2.3 では動作しません。誰かが私が間違ったことを教えてもらえますか?

      URL url = new URL(sUrl);

      URLConnection connection = url.openConnection();         

      connection.connect();                    
      InputStream input = new BufferedInputStream(url.openStream());

      OutputStream output = new FileOutputStream(pathFolder+"/"+fileName);

                 byte data[] = new byte[1024];
                 long total = 0;
                 int count;
                 while ((count = input.read(data)) != -1) {
                     total += count;
                     // publishing the progress....
                     publishProgress((int) (total * 100 / fileLength));
                     output.write(data, 0, count);
                 }

                 output.flush();
                 output.close();
                 input.close();
4

1 に答える 1