I am trying to create a file for my VCR, but this file continues to receive a random name. Since this is difficult to work with, I want to rename the file after creating it with a more meaningful name.
However, although it renameToreturns true, the file has not been renamed.
Am I doing something wrong here?
outfile = File.createTempFile(amount + "_alarmsave", ".3gp",
storageDir);
System.out.println("Old file: "+outfile.getAbsolutePath());
File newFile = new File(outfile.getParent(), "alarmsave_" + amount + ".3gp");
System.out.println("new file: "+newFile.getAbsolutePath());
if(outfile.renameTo(newFile)){
System.out.println("Succes! Name changed to: " + outfile.getName());
}else{
System.out.println("failed");
}
LogCat Output:
01-13 18:27:40.264: I/System.out(22913): Old file: /mnt/sdcard/Personal Alarm/13_alarmsave1623959934.3gp
01-13 18:27:40.264: I/System.out(22913): new file: /mnt/sdcard/Personal Alarm/alarmsave_13.3gp
01-13 18:27:40.284: I/System.out(22913): Succes! Name changed to: 13_alarmsave1623959934.3gp
source
share