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.
--
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en