0

我尝试使用以下代码重命名视频文件:

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");

定位中没有错误 .... 但不执行重命名。

我认为这个问题的原因是因为这个文件在 videoview 中播放所以在我添加的代码之前,videoView.setVideoPath("");但它没有帮助,我需要做什么???

提前谢谢...

4

1 回答 1

1

您已经mediaStorageDir在构造 File 对象时指定了:

File to = new File(mediaStorageDir,mediaFile);

所以你应该删除mediaStorageDir.getPath()from mediaFile,如下所示:

mediaFile = "Your_voice" + timeStamp + ".mp4";

您可能还应该Your_voice从 mediaStorageDir 中删除该部分,只需使用:

mediaStorageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES);
于 2013-06-27T12:39:23.087 回答