file - Android: Unable to play video from private path subdirectory using intent -


i able play video private path /data/data/com.exmaple.ui/files/final.mp4 path.

but unable play subdirectory /data/data/com.exmaple.ui/files/myvideos/final.mp4,

intent intent = new intent(intent.action_view); file playfile = new file("/data/data/com.exmaple.ui/files/myvideos/final.mp4"); intent.setdataandtype(uri.fromfile(playfile), "video/mp4"); startactivity(intent); 

file creation code:

    string path =  getfilesdir().getabsolutepath();     file dest = new file(path,"myvideos");     boolean mkdirs = dest.mkdirs();     file destfinal =  new file(dest,"final.mp4");     destfinal.setreadable(true, false);     copyfileusingfilestreams(inputfile,destfinal); 

copy code:

private void copyfileusingfilestreams(file source, file dest) throws ioexception {      inputstream input = null;     outputstream output = null;      try {         input = new fileinputstream(source);         output = new fileoutputstream(dest);         byte[] buf = new byte[1024];         int bytesread;         while ((bytesread = input.read(buf)) > 0) {             output.write(buf, 0, bytesread);         }         dest.setreadable(true);     } {         input.close();         output.close();     } 

have made file readable,its not allowing me read file above using intents reason?

error : device 1:

07-09 14:22:12.098: w/videoview(17106): unable open content: file:///data/data/com.exmaple.ui/files/myvideos/final.mp4 07-09 14:22:12.098: w/videoview(17106): java.io.ioexception: setdatasource failed. 

error :device 2:

----------private file canread :true exists :true     07-09 20:06:00.636: w/system.err(19371): java.io.filenotfoundexception: /sys/class/tcon/tcon/mode: open failed: enoent (no such file or directory)     07-09 20:06:00.636: w/system.err(19371):    @ libcore.io.iobridge.open(iobridge.java:409)     07-09 20:06:00.636: w/system.err(19371):    @ java.io.fileoutputstream.<init>(fileoutputstream.java:88)     07-09 20:06:00.636: w/system.err(19371):    @ java.io.fileoutputstream.<init>(fileoutputstream.java:73)     07-09 20:06:00.636: w/system.err(19371):    @ com.sec.android.hardware.sechardwareinterface.sysfswrite(sechardwareinterface.java:100)     07-09 20:06:00.636: w/system.err(19371):    @ com.sec.android.hardware.sechardwareinterface.settconuimode(sechardwareinterface.java:343)     07-09 20:06:00.636: w/system.err(19371):    @ com.sec.android.app.videoplayer.activity.movieplayer$sechwinterfacewrapper.settconuimode(movieplayer.java:5980)     07-09 20:06:00.636: w/system.err(19371):    @ com.sec.android.app.videoplayer.activity.movieplayer$24.handlemessage(movieplayer.java:3644)     07-09 20:06:00.636: w/system.err(19371):    @ android.os.handler.dispatchmessage(handler.java:99)     07-09 20:06:00.636: w/system.err(19371):    @ android.os.looper.loop(looper.java:137)     07-09 20:06:00.636: w/system.err(19371):    @ android.app.activitythread.main(activitythread.java:5455)     07-09 20:06:00.636: w/system.err(19371):    @ java.lang.reflect.method.invokenative(native method)     07-09 20:06:00.646: w/system.err(19371):    @ java.lang.reflect.method.invoke(method.java:525)     07-09 20:06:00.646: w/system.err(19371):    @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1187)     07-09 20:06:00.646: w/system.err(19371):    @ com.android.internal.os.zygoteinit.main(zygoteinit.java:1003)     07-09 20:06:00.646: w/system.err(19371):    @ dalvik.system.nativestart.main(native method)     07-09 20:06:00.646: w/system.err(19371): caused by: libcore.io.errnoexception: open failed: enoent (no such file or directory)     07-09 20:06:00.646: w/system.err(19371):    @ libcore.io.posix.open(native method)     07-09 20:06:00.646: w/system.err(19371):    @ libcore.io.blockguardos.open(blockguardos.java:110)     07-09 20:06:00.646: w/system.err(19371):    @ libcore.io.iobridge.open(iobridge.java:393)     07-09 20:06:00.646: w/system.err(19371):    ... 14 more 

wonder how root , subfloder making difference here? restrictions mentioned? file provider or content provider options? nitz

since have exception:

java.io.filenotfoundexception: /sys/class/tcon/tcon/mode: open failed: enoent (no such file or directory) 

means file doesn´t exist or don´t have correct path file.

use instead:

    file playfile = new file(environment.getexternalstoragedirectory() + "/data/data/com.exmaple.ui/files/myvideos/final.mp4");     if(playfile.exists()){          intent.setdataandtype(uri.fromfile(playfile), "video/mp4");         startactivity(intent);     }else{         toast.maketext(getapplicationcontext(), "the file doesn´t exist!", toast.length_long).show();     } 

or

    file playfile = new file(environment.getexternalstoragedirectory() + "/data/data/com.exmaple.ui/files/myvideos", "final.mp4");     if(playfile.exists()){          intent.setdataandtype(uri.fromfile(playfile), "video/mp4");         startactivity(intent);     }else{         toast.maketext(getapplicationcontext(), "the file doesn´t exist!", toast.length_long).show();     } 

and important remember add permission:

   <uses-permission android:name="android.permission.read_external_storage"/> 

Comments