Мое приложение получает следующее исключение во время выполнения:
Код: Выделить всё
java.nio.file.AccessDeniedException: /storage/emulated/0/Download/README.txtКод: Выделить всё
File dir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
File textFile = new File(dir, "README.txt");
String fileContents = "";
try{
fileContents = new String(Files.readAllBytes(textFile.toPath()));
}
catch (IOException e)
{
e.printStackTrace();
}
Код: Выделить всё
Код: Выделить всё
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) !=
PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(
this,
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
REQUEST_READ_FILE);
}
Подробнее здесь: https://stackoverflow.com/questions/788 ... al-storage
Мобильная версия