I've created a basic Audio Recording App using Media Recorder API's. I'm trying to create a folder in the SD card and to save my recorded files to that folder. I'm getting this warning with following code.
File.mkdir() is ignored
// Assign random number to avoid audio file from overwriting
Long tsLong = System.currentTimeMillis()/1000;
// Specify a Location for the recorded file to be stored in the SD card
mFileName = Environment.getExternalStorageDirectory().getAbsolutePath() + "/AudioRecordTest/";
File path = new File(mFileName);
if(!path.exists()) {
path.mkdir();
}
mFileName += "/AudioRecordTest_" + tsLong.toString() + ".mp3";
How to solve this warning message. Feel free to modify the code if there is any other mistake.
As @Stephen C suggests, i handled in these ways
1)
boolean isDirectoryCreated= path.mkdir();
and ignore 'isDirectoryCreated'
2) (Recommended)
boolean isDirectoryCreated=path.exists();
if (!isDirectoryCreated) {
isDirectoryCreated= path.mkdir();
}
if(isDirectoryCreated) {
// do something
}
3)
if (!path.exists()) {
if(path.mkdir()){
// do something
}
}