因此,在我使用 MediaRecorder 录制内容并将其放在 android 设备中的某个位置之后。然后如何重命名该文件?这是我最接近解决方案的方法。单击按钮后,什么也没有发生。
public void nameAlert() {
AlertDialog.Builder nameAlert = new AlertDialog.Builder(this);
nameAlert.setMessage("Name of your recorded file:");
final EditText input = new EditText(this);
nameAlert.setView(input);
nameAlert.setPositiveButton("Enter", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1) {
newFileName = input.getText();
String currentFileName = externalStoragePath;
currentFileName = currentFileName.substring(1);
Log.i(storagePath, currentFileName);
File directory = new File (externalStoragePath);
File from = new File (directory, currentFileName);
File to = new File (directory, newFileName + ".mp3");
from.renameTo(to);
}
});
nameAlert.show();
此外,这可能是相关的。
externalStoragePath = Environment.getExternalStorageDirectory().getAbsolutePath();
日志:
08-02 02:04:03.623: I/(14043): storage/emulated/0