How to save an audio file in internal storage andr

2019-09-19 03:20发布

问题:

I was wondering how can I save an audio file in the Internal storage of my android device. Specifically I would like my app that records sound from the microphone to save this file in the internal storage. I know that for external storage there is something like:

outputFile = Environment.getExternalStorageDirectory()+"/myrecord.3gpp";

Is there anything similar for internal storage also? Thanks!

回答1:

Use getFilesDir()

SDCardpath = getFilesDir();
    myDataPath = new File(SDCardpath.getAbsolutePath()
            + "/.My Recordings");

    // mydir = context.getDir("media", Context.MODE_PRIVATE);
    if (!myDataPath.exists())
        myDataPath.mkdir();


    audiofile = new File(myDataPath + "/" + fileName);

For more see Using the Internal Storage



回答2:

Try this...

outputFile="/sdcard/myrecord.3gpp";