My download video code does not works in android 4.0 -
i have done video file download code application , working perfact version upto 2.3.3 not working in android 4.0 , giving error java.io.filenotfoundexception can me solve problem? in advance
public void video_download(string urlstring, string name) { url url; try { url = new url(urlstring); httpurlconnection c = (httpurlconnection) url.openconnection(); c.setrequestmethod("get"); c.setdooutput(true); c.connect(); string path = environment.getexternalstoragedirectory() + "/application/"; log.v("path", "path: " + path); file file = new file(path); file.mkdirs(); string filename; filename = name + ".mp4"; file outputfile = new file(file, filename); fileoutputstream fos = new fileoutputstream(outputfile); inputstream = c.getinputstream(); byte[] buffer = new byte[1024]; int len1 = 0; while ((len1 = is.read(buffer)) != -1) { fos.write(buffer, 0, len1); } fos.close(); is.close(); } catch (malformedurlexception e) { // todo auto-generated catch block e.printstacktrace(); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } }
Comments
Post a Comment