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. OI Shopping list

The OpenIntents shopping list is available for download at the store
of your choice:

* http://www.openintents.org/en/download
* http://slideme.org/content/oi-shopping-list
* http://andappstore.com/AndroidPhoneApplications/apps/2083

The Open Intents Shopping list lets you keep track of your shopping
items. You can also use it for other kinds of check lists, for example
for ToDo lists or party guest lists.

Your feedback is welcome!

Peli
www.openintents.org



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

2. Issue with Calendar APIs

Hi all,

I am facing an issue with Android's Calendar API. When I get a
Calendar instance with Calendar.getInstance(TimeZone) method with a
Timezone other than the default time zone of the emulator/device, the
returned calendar still has the default timezone. For example, my
default timezone of India (GMT+5.30), and I get a calendar instance
with time zone of US (GMT-700) I always get time of default time zone
when I call getTime() or get default time zone when I call
getTimeZone() method of calendar instance.

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

3. RingtoneManager

4. Long Clickable View

5. How do I get an instance of android.content.pm.PackageInfo to read the attributes on my manifest file?

6. WebView opens links in default browser instead of using itself

7. Error from Make: 'CSSPropertyID' was not declared in this scope...