I recently noticed that when I tried to run my application on Gingerbread emulation, this FTP broke. I am currently using the external apache commons library to support FTP, but for some reason it works on any other Android OS except 2.3 (Gingerbread)
Here is my FTP code
FTPClient ftp = new FTPClient(); ftp.connect(SERVER); ftp.login("anonymous", "anonymous"); ftp.setFileType(FTP.BINARY_FILE_TYPE); ftp.enterLocalPassiveMode(); InputStream is = ftp.retrieveFileStream("file.txt"); byte[] data = new byte[1024]; fos = openFileOutput(FILENAME, Context.MODE_PRIVATE); int x = 0; while((x=is.read(data,0,1024))>=0){ fos.write(data,0,x); } fos.flush(); fos.close(); ftp.logout(); ftp.disconnect();
As I said, this is tested and works on 1.6, 2.1 and 2.2, but not 2.3. I tried all day to find out why and how to fix it, but I can not find any solution.
So I wondered if anyone had any experience with FTP and Gingerbread, and if you would be so pleased to lead me in the right direction.
Thanks.
android ftp
ernie
source share