public void saveByteArrayToFile(Context context){
Log.v(TAG, "Save byte array to file");
switch(mType){
case ChatMessage.AUDIO_MESSAGE:
filePath = context.getApplicationContext().getExternalFilesDir(Environment.DIRECTORY_MUSIC).getAbsolutePath()+"/"+fileName;
break;
case ChatMessage.VIDEO_MESSAGE:
filePath = context.getApplicationContext().getExternalFilesDir(Environment.DIRECTORY_MOVIES).getAbsolutePath()+"/"+fileName;
break;
case ChatMessage.FILE_MESSAGE:
filePath = context.getApplicationContext().getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath()+"/"+fileName;
break;
case ChatMessage.DRAWING_MESSAGE:
filePath = context.getApplicationContext().getExternalFilesDir(Environment.DIRECTORY_PICTURES).getAbsolutePath()+"/"+fileName;
break;
}
System.out.println("Mera path"+filePath);
File file = new File(filePath);
if (file.exists()) {
file.delete();
}
try {
FileOutputStream fos=new FileOutputStream(file.getPath());
fos.write(byteArray);
fos.close();
Log.v(TAG, "Write byte array to file DONE !");
}
catch (java.io.IOException e) {
e.printStackTrace();
Log.e(TAG, "Write byte array to file FAILED !");
}
}
java.io.FileNotFoundException:/ストレージ/ sdcard0 /アンドロイド/データ/ ... によって引き起こさ:android.system.ErrnoException:失敗開けません:ENOENT(そのようなファイルまたはディレクトリ)エラーを取得
ファイルの作成中にこのエラーが発生します。
で説明するよう、実行時のアクセス権を要求する必要が23+
そのパスに書き込みますか? – LEQADA