デバイスの SD にファイルを作成しようとしています。これは 1 週間前には機能していましたが、現在は機能していません。その理由がわかりません。
Logcat は以下を出力します。
java.io.FileNotFoundException ...pathtofile... (no such file or directory)
したがって、ファイルは作成されていません。私はアンドロイドマニフェストに正しい権限を持っています:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
この方法でファイルを作成します。
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)){
base = Environment.getExternalStorageDirectory().getAbsolutePath();
}
String fname = File.separator +"VID_"+ timeStamp + ".3gp";
mediaFile = new File(base+fname);
次に、存在するかどうかを確認します。
if(mediaFile.exists()){
Log.v("mediaFile","ex");
}else{
Log.v("mediaFile","no ex");
}
ログには、IT DOESN'T EXIST と書かれています。私も file.createNewFile() を試しましたが、うまくいきません。
それで、一週間前は動いていたのに、今は動かないのです。SDカードに問題があるのかもしれません???? それはある種のバグである可能性があります!!!????
ありがとう
編集:その他のコード
ファイルが作成される関数は次のとおりです。
private static File getOutputMediaFile()
呼び出し元:
private static Uri getOutputMediaFileUri(){
return Uri.fromFile(getOutputMediaFile());
}
そして、次のように mediarecorder の出力に設定されます。
vMediaRecorder.setOutputFile(getOutputMediaFileUri().toString());
したがって、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;**
}
太字のキャッチは、実行して出力するものです。
java.io.FileNotFoundException ...pathtofile... (no such file or directory)