i have videoview plays video path corresponds video file within android gallery
videoview videoview1 = (videoview)promptsview.findviewbyid(r.id.videoview09); string srcpath = "/storage/emulated/0/dcim/camera/20150824_210148.mp4"; videoview1.setvideopath(srcpath); videoview1.requestfocus(); videoview1.start();
now, need somehow store video videoview internal storage app privately.
i've managed photos using
public string saveimagetointernalstorage(bitmap image, string imgrequestedname) { contextwrapper cw = new contextwrapper(getactivity()); file directory = cw.getdir("imagedir", context.mode_private); file mypath=new file(directory,imgrequestedname+".jpg"); string loc = mypath.getabsolutepath(); fileoutputstream fos = null; try { fos = new fileoutputstream(mypath); image.compress(bitmap.compressformat.jpeg, 70, fos); sharedpreferences pref = getactivity().getapplicationcontext().getsharedpreferences("mypref", context.mode_private); final sharedpreferences.editor editor = pref.edit(); editor.putint("totalimagecount",(pref.getint("totalimagecount",0))+1); editor.commit(); fos.close(); } catch (exception e) { e.printstacktrace(); } return mypath.getabsolutepath(); }
how can equivalent videos?
and how can read video internal storage?
saving video using it's path internal storage :
contextwrapper cw = new contextwrapper(getactivity()); file directory = cw.getdir("viddir", context.mode_private); file mypath=new file(directory,vidrequestedname+".mp4"); try { fileoutputstream newfile = new fileoutputstream (mypath); //path 0 = current path of video fileinputstream oldfile = new fileinputstream (path0); // transfer bytes in out byte[] buf = new byte[1024]; int len; while ((len = oldfile.read(buf)) > 0) { newfile.write(buf, 0, len); } newfile.flush(); newfile.close(); oldfile.close();
Comments
Post a Comment