在 newfolder 中的 Sqlite 中存储音频

Storage Audio in Sqlite in newfolder

我使用这样的代码,它对我来说工作得很好

String fileName = Environment.getExternalStorageDirectory() +"/Music/Diary.flac";

音乐文件夹已经存在是SD卡,我想在SD卡中自动创建文件夹新文件夹,我试过类似的东西

String fileName = Environment.getExternalStorageDirectory() +"/NewFolder/Diary.flac";

但它不起作用

您需要先创建一个目录。试试这个:

File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/NewFolder", "/Diary.flac");
    file.getParentFile().mkdir();
    if(!file.exists()){
        try {
                  file.createNewFile();
              } catch (IOException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
    }