I am trying to write a new wave file to the Ringtones folder on external storage. But unfortunately the file is not being created.
I have followed the android docs on how to do this, and have implemented it the way it is suggested.
I have also added the proper permissions in manifest. As well, I have checked that my device external storage is readable/writable.
The following code writes the log statement "directory not created". As well, any subsequent calls to stream cause nullPointer.
public WavFileOutStream(String fileName)
{
// Get the directory for the user's public pictures directory.
File file = new File(Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_RINGTONES), fileName);
if (!file.getParentFile().mkdirs()) {
Log.e("trace", "Directory not created");
}
try {
stream = new DataOutputStream(new FileOutputStream(file));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}