FTP Download "Read-only file system" error Android

0

I have a problem when trying to download a test file to my FTP server, it will respond with "Read-only file system". Thanks in advance.

    public boolean Conectar(String host, int port, String user, String pass){
        boolean status;
        try {
            connect(host, port);
            enterLocalPassiveMode();
            if (FTPReply.isPositiveCompletion(getReplyCode())) {
                login(user, pass);
                setFileType(BINARY_FILE_TYPE);
            }
            Log.i(TAG, "Se conectou ao servidoor.");
            status = true;
            } catch (Exception e) {
            Log.e(TAG, "Não foi possível se conectar ao servidor. "+e.getMessage);
            status = false;
        }
        return status;
    }

public void Download(){
    try{
        String filename = "teste.xml";
        FileOutputStream fos = new FileOutputStream(filename);
        retrieveFile("/"+filename,fos);
    }catch(Exception e){
        Log.e(TAG, " "+e.getMessage());
    }
}
    
asked by anonymous 30.10.2018 / 13:01

1 answer

0
retrieveFile("/"+filename,fos);

You are trying to save the file to the system root, which is write protected, hence the error.

Font

    
30.10.2018 / 13:38