Tengo un archivo de vídeo (MP4 formato) y quiero para permitir que el usuario sea capaz de descargar el vídeo a su SD card.I utilizar actualmente este código, pero no su trabajo ..¿Cómo puedo descargar un archivo de video a la tarjeta SD?
String PATHSdcard = "/sdcard/Video/";
public void DownloadFromUrl(String VideoURL, String fileName)
try { URL url = new URL("https://javmed-prod.s3.amazonaws.com/666034cbe81045f2a2da50e5205e376b.mp4");
File file = new File(fileName);
long sTime = System.currentTimeMillis();
URLConnection URLcon = url.openConnection();
InputStream is = URLcon.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is);
ByteArrayBuffer baf = new ByteArrayBuffer(50);
int current = 0;
while ((current = bis.read()) != -1) {
baf.append((byte) current);
}
FileOutputStream fos = new FileOutputStream(PATHSdcard+file);
fos.write(baf.toByteArray());
fos.close();
} catch (IOException e) {
Log.d("ERROR.......",e+"");
}
¡Gracias por cualquier ayuda!
¿Qué usted intentó antes? – user370305
¿dónde está la fuente del video? ¿Está alojado en el servidor http? – momo
http://stackoverflow.com/questions/3692252/android-how-do-i-download-a-video-file-to-sd-card possible duplicate. –