Сохранение общедоступного файла
Как сохранить данные в файл, чтобы его можно было использовать (отправлять, читать и т.п.)? разрешения выданы
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
Файл у меня сохраняется, в диспетчере на телефоне я его вижу(а на компе в проводнике нет), через DeviceFileExplorer в Android Studio он открывается и в нем правильные данные (как они и должны быть), но на телефоне Notepad++ файл видит, но не открывает, пишет "файл не найден"
private void saveToOuter(){
String message = "$Lat:344;Lon:335;Alt:4.5";
String state = Environment.getExternalStorageState();
if (state.equals(Environment.MEDIA_MOUNTED)) {
// Available to read and write
Log.i("MyLog", "read and write ");
try {
FileOutputStream fos = new FileOutputStream(getExternalPath());
fos.write(message.getBytes());
fos.close();
Log.i("MyLog", "All Write " + getExternalPath().getAbsolutePath());
} catch (FileNotFoundException e) {
Log.i("MyLog", "HUY ");
e.printStackTrace();
} catch (IOException e) {
Log.i("MyLog", "HUY 2");
e.printStackTrace();
}
}
else if (state.equals(Environment.MEDIA_MOUNTED_READ_ONLY)) {
// Available to at least read
Log.i("MyLog", "only read ");
} else {
Log.i("MyLog", "give me sdCard");
}
}
private File getExternalPath() {
for(File file : Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).listFiles()){
Log.i("MyLog", "getExternalPath " + file.getName());
}
File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS),fileName);
//File file =new File(getExternalFilesDir(null), fileName);
return file;
}
Ощущение, как будто к нему заблокирован доступ.