I receive an error when trying to save a voice message after recording it. It only happens when I add a dateTime instance added as a string to the voice message path like this: "myRecording 2015 17:33:30.3gp" but never happens when I leave the dateTime instance out. However, I would like to have the dateTime instance added to the path.
My code for setting up the path looks like this:
public VoiceRecorder() {
DateFormat dateFormat = DateFormat.getDateTimeInstance();
String date = dateFormat.format(new Date());
String dir = Environment
.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC)
+ "/MyRecordings";
File newdir = new File(dir);
if (!newdir.exists())
newdir.mkdirs();
filePath = dir + "/myVoiceRecording " + date +".3gp";
}
The error message I receive is:
QCMediaPlayer could not be located.... QCMediaPlayer mediaplayer NOT present error (1, -2147483648) prepare() failed
I receive this error on the emulator and on my phone. Since it works when I do not add a dateTime instance, I assume that there is something wrong with the way the final path is interpreted by the media player but I cannot figure out what the issue might be, can anyone here help me out?
Thanks in advance!
It seems colon ":" is not allowed in the android filesystem. you can probably do it with underscores
SimpleDateFormat formatter = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss");
Date now = new Date();
String date = formatter.format(now);
...
...
filePath = dir + "/myVoiceRecording" + date +".3gp";