我尝试使用以下代码重命名视频文件:
File from = new File(outputFileName);
File to = new File(mediaStorageDir,mediaFile);
from.renameTo(to);
当
outputFileName = //mnt/sdcard/Movies/Your_voice/Your_voice.mp4
和
mediaFile = mediaStorageDir.getPath() + File.separator
+ "Your_voice" +
timeStamp +
".mp4";
和
mediaStorageDir = new File(
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES),
"Your_voice");
locat没有错误....但不执行重命名。
我认为这个问题是因为这个文件在videoview中播放所以在我添加videoView.setVideoPath("");
的代码之前,但它没有帮助,我需要做什么?
向前谢谢......
答案 0 :(得分:1)
在构造File对象时已经指定了mediaStorageDir
:
File to = new File(mediaStorageDir,mediaFile);
因此您应该从mediaStorageDir.getPath()
中移除mediaFile
,如下所示:
mediaFile = "Your_voice" + timeStamp + ".mp4";
您可能还应该从mediaStorageDir中删除Your_voice
部分,只需使用:
mediaStorageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES);