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 =
OutputStreamWriter osw = new OutputStreamWriter(fOut);

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

Step 2: open and connect to ftp server

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

Step 3: Store samplefile.txt in FTP server

InputStream input;
                                String path = new
                                Log.i("FTP", path);
                                input = new FileInputStream("samplefile.txt");



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. Extending or replacing existing Android Appa

I copied the Launcher source code from the master (Git) Android source
and created an Eclipse Android 1.6 project using existing code.
Several Java problems exist relating to fields that can not be
resolved. For example: Workspace.java and several other classes have
"mScrollX cannot be resolved" problems. mScrollX is a field in the
View class and Workspace extends ViewGroup, which extends View. Also,
the View class is imported.

Question 1: Why is this not resolved?

Upon examining the contents of the SDK 1.6 android.jar, I see the
implementation of View in the android.jar is nothing like the master
Git Android source code for View. All of the View methods in the SDK
1.6 version of View only contain a "throw new RuntimeException
( "Stub!" )" statement.

Question 2: What's happening here?

Question 3: How do I pull app source code from the master Git and pull
it into Eclipse to either extend it, refactor it, of derive a new app
from it?



2. XML reading/parsing


I have a big problem with the XML parsing in Android. I can't use it
at the following XML file:

<?xml version='1.0' encoding='UTF-8'?>
<osm version='0.6' generator='JOSM'>
  <node id='-1' visible='true' lat='-1.377' lon='-1.3635' />
  <node id='-2' visible='true' lat='-2.493' lon='-0.8684999999999999' /
  <node id='-3' visible='true' lat='-2.889' lon='-0.2925' />
  <node id='-4' visible='true' lat='-2.1731531008265907'
lon='-1.0103675762462703' />
  <node id='-5' visible='true' lat='-1.17173167547311'
lon='-0.39861659247471204' />
  <node id='-6' visible='true' lat='-0.6922364241169185'
lon='-0.10570125802657904' />
  <node id='-7' visible='true' lat='3.033' lon='-3.4425' />
  <node id='-8' visible='true' lat='1.809' lon='-3.7754999999999996' /
  <node id='-9' visible='true' lat='1.341' lon='-4.0275' />
  <node id='-10' visible='true' lat='1.143' lon='-4.0634999999999994' /
  <node id='-11' visible='true' lat='1.008' lon='-4.0095' />
  <node id='-12' visible='true' lat='0.9179999999999999'
lon='-3.9465' />
  <node id='-13' visible='true' lat='2.3983853072967456'
lon='-3.6151525266913263' />
  <node id='-14' visible='true' lat='1.1499578470195202'
lon='-2.6031083483750397' />
  <node id='-15' visible='true' lat='-1.5140421529804802'
lon='1.338891651624961' />
  <node id='-16' action='modify' visible='true'
lat='-2.7920421529804806' lon='3.660891651624961' />
  <node id='-17' action='modify' visible='true'
lat='-0.8300421529804803' lon='4.6688916516249614' />
  <node id='-18' visible='true' lat='1.3479578470195202'
lon='0.2993916516249608' />
  <node id='-19' visible='true' lat='1.0257578470195203'
lon='0.9437916516249611' />
  <way id='-20' action='modify' visible='true'>
    <nd ref='-7' />
    <nd ref='-13' />
    <nd ref='-8' />
    <nd ref='-9' />
    <nd ref='-10' />
    <nd ref='-11' />
    <nd ref='-12' />
    <nd ref='-1' />
    <nd ref='-4' />
    <nd ref='-2' />
    <nd ref='-3' />
    <tag k='ref' v='43' />
    <tag k='highway' v='primary' />
    <tag k='name' v='Szegi t' />
  <way id='-21' action='modify' visible='true'>
    <nd ref='-13' />
    <nd ref='-18' />
    <nd ref='-19' />
    <nd ref='-17' />
    <tag k='ref' v='Ffasor' />
    <tag k='highway' v='unclassified' />
    <tag k='name' v='Ffasor' />
  <way id='-22' action='modify' visible='true'>
    <nd ref='-4' />
    <nd ref='-5' />
    <nd ref='-6' />
    <nd ref='-19' />
    <tag k='highway' v='unclassified' />
    <tag k='name' v='Thkly utca' />
  <way id='-23' action='modify' visible='true'>
    <nd ref='-5' />
    <nd ref='-14' />
    <nd ref='-8' />
    <tag k='highway' v='unclassified' />
    <tag k='name' v='Derkovits fasor' />
  <way id='-24' action='modify' visible='true'>
    <nd ref='-6' />
    <nd ref='-15' />
    <tag k='highway' v='unclassified' />
    <tag k='name' v='Hrsfa utca' />
  <way id='-25' action='modify' visible='true'>
    <nd ref='-15' />
    <nd ref='-16' />
    <tag k='highway' v='unclassified' />
    <tag k='name' v='Katalin utca' />
  <way id='-26' action='modify' visible='true'>
    <nd ref='-16' />
    <nd ref='-17' />
    <tag k='highway' v='unclassified' />
    <tag k='name' v='?gnes utca' />

I would be grateful if you could help me. I need this numbers to my
map application.
Could you write me source-code in Android?



3. ADT not showing in Europa

4. Ubuntu Karmic Koala (9.10)

5. Task or application equivalent of onPause

6. Enabling SVG in Android's Webkit

7. android 1.6 emulator not shown in ddms