How to programmatically transfer a file from a PC to an Android device using ftp server / client

I am new to Android and ftp programming. Currently on a project to create an Android application to transfer a file from a PC to an android device and verse. I can transfer the file from the Android device to the PC using the ftp server / client method. However, I encounter difficulties in how to push a file from a PC to an Android device. Is it possible to push a file from an ftp server (PC) to a client using an ftp server / client? Or any alternatives for this? Is there any tutorial / example that I could go through?

Any help would be greatly appreciated. Many thanks!

Transfer from android device to PC (Android client side):

FTPClient mFTP = new FTPClient();
try {
    // Connect to FTP Server
    mFTP.connect("192.168.0.103");
    mFTP.login("user", "password");
    mFTP.setFileType(FTP.BINARY_FILE_TYPE);
    mFTP.enterLocalPassiveMode();

    File file = new File(f);

    BufferedInputStream buffIn=null;
    buffIn=new BufferedInputStream(new FileInputStream(file));
    mFTP.enterLocalPassiveMode();
    mFTP.storeFile(filename, buffIn);
    buffIn.close();

    mFTP.logout();
    mFTP.disconnect();          
} catch (SocketException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
} catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}
+4

All Articles