In my app I am trying to create a file and write to it.
This is my code:
try {
File tmpDir = new File("/sdcard/LivingstoneTemp/");
tmpDir.mkdirs();
String filename = "Livingstone_" +UUID.randomUUID() + ".html";
File outputFile = new File(tmpDir, filename);
FileOutputStream fos = new FileOutputStream(outputFile);
byte[] data = response.getBytes();
fos.write(data);
fos.flush();
fos.close();
} catch (Exception e) {
Log.i("LivingstoneInfo", "Error: " + e.getMessage());
}
Permissions:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
I get a "No such file or directory" exception.
I'm running this on a Nexus 5 with an internal storage.