karim_mis
karim_mis

Reputation: 53

Storage Audio in Sqlite in newfolder

I use thus code and it works fine with me

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

Music folder is already exist is SD card , I want to make folder New Folder created automatically in SD card , I tried something like that

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

but it's not working

Upvotes: 0

Views: 31

Answers (1)

Vikalp
Vikalp

Reputation: 2161

You need to create a directory first. Try this:

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();
              }
    }

Upvotes: 1

Related Questions