我试图在我的应用中录制一个声音,然后将其存储在res文件夹中。我做的更多的是以下内容:
private MediaRecorder recorder;
static final String OUTPUT_FILE = "/MediaPlayer/res/raw/recordoutput.3gpp"; //MediaPlayer is the java class and raw is the folder that I would like to put my recorded voice in
private void beginRecording() throws Exception{
killMediaRecorder(); //I implemented this function to kill the existing recorder
File outFile = new File(OUTPUT_FILE);
if(outFile.exists())
{
outFile.delete();
}
recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setOutputFile(OUTPUT_FILE);
recorder.prepare();
recorder.start();
}
清单:
<uses-permission android:name="android.permission.RECORD_AUDIO" />
但在我运行模拟器之后,原始文件中没有创建文件,有人可以帮忙吗?
答案 0 :(得分:1)
答案 1 :(得分:0)
您无法写入 res 文件夹,apk中的所有内容都将只读。您必须将文件保存在内部存储或 SD卡
中