I'm trying to create a file on the SD on my device. This worked a week ago, but now it isn't, and I don't understand why.
The Logcat prints:
java.io.FileNotFoundException ...pathtofile... (no such file or directory)
So, the file is not being created. I have the correct permissions on the android manifest:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
I create the file this way:
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)){
base = Environment.getExternalStorageDirectory().getAbsolutePath();
}
String fname = File.separator +"VID_"+ timeStamp + ".3gp";
mediaFile = new File(base+fname);
Then I check if it exists:
if(mediaFile.exists()){
Log.v("mediaFile","ex");
}else{
Log.v("mediaFile","no ex");
}
And the log says that IT DOESN'T EXIST. I also have tried with file.createNewFile() and it doesn't work.
So, a week ago it was working, now it doesn't work, it could be a problem with the SD card ???? Could it be some type of BUG!!!????
Thanks
EDIT: More Code
The function where the file is created is :
private static File getOutputMediaFile()
Called from:
private static Uri getOutputMediaFileUri(){
return Uri.fromFile(getOutputMediaFile());
}
And setted to mediarecorder output as:
vMediaRecorder.setOutputFile(getOutputMediaFileUri().toString());
So, when I do mediarecorder.prepare():
try {
vMediaRecorder.prepare();
} catch (IllegalStateException e) {
Log.v("RELEASE VIDREC1",e.toString());
releaseMediaRecorder();
return false;
} **catch (IOException e) {
Log.v("RELEASE VIDREC2",e.toString());
releaseMediaRecorder();
return false;**
}
The bold catch is the one that runs, and prints:
java.io.FileNotFoundException ...pathtofile... (no such file or directory)