OmRecorder icon indicating copy to clipboard operation
OmRecorder copied to clipboard

File gets corrupted , Renaming mp3 file after recording

Open Zulqurnain opened this issue 6 years ago • 0 comments

Hi, I am trying to rename the file after it is recorded by Omrecorder , suppose Omrecorder recorder file was "temp-file.mp3" after recording I want it to be meaningful so i change it to "new-recording-code-001.mp3". To rename I wrote this piece of code:

public static boolean renameFile(String fromFilePathWithExt,String toFilePathWithExt){
        LogUtils.d("from: "+fromFilePathWithExt);
        LogUtils.d("to: "+toFilePathWithExt);
        File dir = Environment.getExternalStorageDirectory();
        if(dir.exists()){
            File from = new File(fromFilePathWithExt);
            File to = new File(toFilePathWithExt);
            if(from.exists()) {
                return from.renameTo(to);
            }
        }
        return false;
    }

This function is working and it renames the file and returns true , but after changing the filename, FILE GETS CORRUPTED AND DOES NOT PLAY.

Am I doing something wrong? or this is library bug.

Zulqurnain avatar Feb 15 '19 04:02 Zulqurnain