How to save an audio file in internal storage android

荒凉一梦 提交于 2020-01-06 17:09:25

问题


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";


来源:https://stackoverflow.com/questions/30661338/how-to-save-an-audio-file-in-internal-storage-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!