Я создаю File
.Работает во всех версиях, кроме Pie Version.Это мой код
private void writeToFile(String data, Context context) {
try {
File file = new File(Environment.getExternalStorageDirectory() + File.separator + "testApp.txt");
if (!file.exists()) {
file.createNewFile();
}
FileWriter writer = new FileWriter(file);
writer.append(data);
writer.flush();
writer.close();
} catch (IOException e) {
Log.e("Exception", "File write failed: " + e.toString());
}
}