0

我试图在我的应用程序中录制声音,然后将其存储在 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" />

但是在我运行模拟器后,原始文件中没有创建文件,有人可以帮忙吗?

4

2 回答 2

1

不可以,应用程序不能写入其他应用程序的内部存储。

你也可以,

  1. 将文件写入应用的内部存储。
  2. 将文件写入设备的外部存储。

两者都在文档中进行了详细描述。

于 2012-06-26T03:47:43.790 回答
0

不能写入res文件夹,apk 中的所有内容都是只读的。您必须将文件保存在内部存储器SD 卡中

于 2012-06-26T04:03:27.563 回答