Androidでfile-Aをfolder-Bにコピーするときは、を使用したいと思いますProgressDialog(ProgressDialog.STYLE_HORIZONTAL)
。
例1:
String mStart = "/sdcard/aaaa/";
FileInputStream fis = new FileInputStream(mStart);
FileOutputStream fos = new FileOutputStream(path);
FileChannel fin = fis.getChannel();
FileChannel fout = fos.getChannel();
File f = new File(mStart);
fin.transferTo(0, f.length(), fout);
例2:
byte[] buffer = new byte[1024];
while ((readcount = bin.read(buffer, 0, 1024)) != -1) {
bout.write(buffer, 0, readcount);
publishProgress(readcount);
}
2番目の例を使用する場合は使用できますProgressDialog()
が、最初の例では使用できません。メソッドProgressDialog
を使用する場合、どうすれば更新できますか?transferTo()