FTP client : How to change working directory

by Guru » Fri, 23 Apr 2010 08:02:05 GMT


Sponsored Links
 Hi friends,
I am beginner to android. I am trying to develop FTP client in
android. I am unable to change the working directory.
I am using FileZilla FTP server.
I want to upload one file (samplefile.txt) to FTP server. So,

Step 1: I created this file using
FileOutputStream fOut =
openFileOutput("samplefile.txt",MODE_WORLD_READABLE);
OutputStreamWriter osw = new OutputStreamWriter(fOut);
osw.write(TESTSTRING);
osw.flush();
osw.close();

and I confirmed this file got created in "/data/data/com.xyz.Hello/
files/samplefile.txt"

Step 2: open and connect to ftp server

ftp.connect("107.108.yy.xx", 4000);
ftp.login(username, password);
ftp.setFileType(FTP.ASCII_FILE_TYPE);
ftp.port(ftp.getRemoteAddress(), ftp.getRemotePort());

Step 3: Store samplefile.txt in FTP server

{
InputStream input;
                                String path = new
java.io.File(".").getCanonicalPath();
                                Log.i("FTP", path);
                                input = new FileInputStream("samplefile.txt");

                                ftp.storeFile(ftp.printWorkingDirectory(),
input);

                                input.close();
}

Problem: In the step 3, when I do  String path = new
java.io.File(".").getCanonicalPath(); I am getting root directory "/".
But my file is in "/data/data/com.xyz.Hello/files/samplefile.txt". So
I should do change working directory to "/data/data/com.xyz.Hello/
files". But I am not getting how to do this in android? Please help me
to know how to change the working directory. and also let me know if
there is any code help on creating FTP on android.

--



Other Threads

1. How to publish application to own device without Android Market?

You can do this in 2 ways:

- If you have adb debugging enabled on your device, use "adb install
myapp.apk" to install it over USB.

- Or upload it to any web server that you can access via the device
web browser (if you're on a local network wifi, any local web server
will do.) Browse the URL of the APK via the web browser, download it
and install it.

R/




--~--~---------~--~----~------------~-------~--~----~

2. Sending SMS messages between AVDs (in Eclips)

I am using Android Eclipse plug in and before the upgrade to the 1.5
SDK I was able shoot messages (SMS) between two emulators just by
using the number that appeared at the top of the emulator window
(5554 , 5556 etc.).

This functionality is not longer working with the 1.5 SDK (at least
for me).

Thoughts on how to make it work?

Lior
--~--~---------~--~----~------------~-------~--~----~

3. android.bat -> NullPointerException for making AVD file !

4. How to create a Toast from a background operation?

5. Suggestion about android.graphics.path for performance

6. Button Listeners

7. how to add a button widget to a custom ImageView.