Пытаюсь сохранить скаченный файл и выдается - java.io.FileNotFoundException: /1.gif: open failed: EROFS (Read-only file system)
Как это исправиль??
в коде пометил где выпадает ошибка.
private String saveFilePatch = "/1.gif";
private ProgressDialog dialog = null;
private String urlFile="https://vk.com/doc430279622_445877224?hash=d20c78fff02c29f267&dl=GQZTAMRXHE3DEMQ:1496394942:6d9c703cd7409eda1b&api=1&no_preview=1";
private void downloadFile(String url, String saveFilePatch){
try {
File SaveFile = new File(saveFilePatch);
URL u = new URL(url);
URLConnection con = u.openConnection();
int lengthofContext = con.getContentLength();
DataInputStream dataInputStream = new DataInputStream(u.openStream());
byte[] buffer = new byte[lengthofContext];
dataInputStream.readFully(buffer);
dataInputStream.close();
FileOutputStream fos = new FileOutputStream(SaveFile);
<b> // ошибка выпадает в этой строке</b>
DataOutputStream dataOutputStream = new DataOutputStream(fos);
dataOutputStream.write(buffer);
dataOutputStream.flush();
dataOutputStream.close();
fos.close();
hideProgressIndicator();
}catch (IOException e){
hideProgressIndicator();
e.printStackTrace();
}
catch (Exception e){
e.printStackTrace();
}
}
private void hideProgressIndicator() {
runOnUiThread(new Runnable() {
@Override
public void run() {
dialog.dismiss();
}
});
}
public void onClickBtnTwo(View view) {
if (urlFile != "") {
dialog = ProgressDialog.show(MainActivity.this, "", "Download...", true);
new Thread(new Runnable() {
@Override
public void run() {
downloadFile(urlFile, saveFilePatch);
}
}).start();
}else {
System.out.println("null photo");
}
}
в манифесте прописано
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />