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:/storage/sdcard0/Android/data/... Verursacht durch: android.system.ErrnoException: Öffnen fehlgeschlagen: ENOENT (Keine solche Datei oder das Verzeichnis)Erste Fehler beim Erstellen von Datei
Ich erhalte diesen Fehler beim Erstellen der Datei.
Vielleicht haben Sie keine Berechtigung zum schreibe auf diesen Pfad? – LEQADA