繁体   English   中英

在SD卡Android上的“音乐目录”中保存文件

[英]Save File in Music Directory on Sd Card Android

如何将.mp3文件保存到sdCard上的“音乐”目录中。

以下代码始终将文件保存到没有任何扩展名的downloads文件夹中

   private FileOutputStream getOutStream(String fileName) throws FileNotFoundException{
    if (Environment.getExternalStorageState().equals(
            Environment.MEDIA_MOUNTED)) {
        String sdpath = Environment.getExternalStorageDirectory()
                + "/";
        mSavePath = sdpath + "download";
        File file = new File(mSavePath);

        if (!file.exists()) {
            file.mkdir();
        }
        File saveFile = new File(mSavePath, fileName);
        return new FileOutputStream(saveFile);
        }else{
        mSavePath = mContext.getFilesDir().getPath();
        return mContext.openFileOutput(fileName ,          Context.MODE_WORLD_READABLE);
    }
     } 
 mSavePath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC);
 File file = new File(mSavePath+"/filename.mp3");

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM