0
我試圖在AsycTask的內部存儲器中下載視頻。我的代碼工作正常。我的日誌表示視頻已下載。但是,我無法找到該文件夾,也沒有在我的手機文件。無法在內部存儲器中存儲視頻文件Android
這裏是我的代碼:
String nameoffile = mInfo.getFilename() + "." + mInfo.getFileType();
File rootdirectory= cw.getFilesDir().getAbsoluteFile();
if (!rootdirectory.exists()) {
rootdirectory.mkdirs();
}
File file = new File(rootdirectory, nameoffile);
file.createNewFile();
Log.e("DEVICE", "file created");
Log.e("DEVICE", "" + nameoffile);
InputStream input = new BufferedInputStream(url.openStream(), 8192);
OutputStream output = new FileOutputStream(file);
byte data[] = new byte[1024];
long total = 0;
while ((count = input.read(data)) != -1) {
total += count;
progress = (int) ((total * 100)/lenghtOfFile);
publishProgress(progress);
Log.e("PROGRESS", "" + mInfo.getFileType() + progress);
mInfo.setFilePercent(progress);
output.write(data, 0, count);
i = 1;
}
Log.e("Download Complete", "" + Mvalue);
// flushing output
output.flush();
// closing streams
output.close();
input.close();
Log.e("Download Complete", "" + 0);