我能够从私人通道播放视频/data/data/com.exmaple.ui/files/final.mp4这条道路。
但无法从子目录喜欢玩/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);
文件创建的代码:
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);
复制代码:
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);
} finally {
input.close();
output.close();
}
取得了文件的可读性,它不是让我读文件像上面使用意图的原因吗?
错误:设备1:
07-09 14:22:12.098: W/VideoView(17106): Unable to 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.
错误:设备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): at libcore.io.IoBridge.open(IoBridge.java:409)
07-09 20:06:00.636: W/System.err(19371): at java.io.FileOutputStream.<init>(FileOutputStream.java:88)
07-09 20:06:00.636: W/System.err(19371): at java.io.FileOutputStream.<init>(FileOutputStream.java:73)
07-09 20:06:00.636: W/System.err(19371): at com.sec.android.hardware.SecHardwareInterface.sysfsWrite(SecHardwareInterface.java:100)
07-09 20:06:00.636: W/System.err(19371): at com.sec.android.hardware.SecHardwareInterface.setTconUIMode(SecHardwareInterface.java:343)
07-09 20:06:00.636: W/System.err(19371): at com.sec.android.app.videoplayer.activity.MoviePlayer$SecHWInterfaceWrapper.setTconUIMode(MoviePlayer.java:5980)
07-09 20:06:00.636: W/System.err(19371): at com.sec.android.app.videoplayer.activity.MoviePlayer$24.handleMessage(MoviePlayer.java:3644)
07-09 20:06:00.636: W/System.err(19371): at android.os.Handler.dispatchMessage(Handler.java:99)
07-09 20:06:00.636: W/System.err(19371): at android.os.Looper.loop(Looper.java:137)
07-09 20:06:00.636: W/System.err(19371): at android.app.ActivityThread.main(ActivityThread.java:5455)
07-09 20:06:00.636: W/System.err(19371): at java.lang.reflect.Method.invokeNative(Native Method)
07-09 20:06:00.646: W/System.err(19371): at java.lang.reflect.Method.invoke(Method.java:525)
07-09 20:06:00.646: W/System.err(19371): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187)
07-09 20:06:00.646: W/System.err(19371): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
07-09 20:06:00.646: W/System.err(19371): at 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): at libcore.io.Posix.open(Native Method)
07-09 20:06:00.646: W/System.err(19371): at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
07-09 20:06:00.646: W/System.err(19371): at libcore.io.IoBridge.open(IoBridge.java:393)
07-09 20:06:00.646: W/System.err(19371): ... 14 more
不知道根subfloder如何使这里的区别? 任何限制提到? 文件提供商或内容提供商选择呢? 由于尼茨