I did this. Just open a connection with your server (if it is a FTP server, just do it with FTPClient
from the Apache commons). Get this connection setting up into a new AsyncTask<...,...,...>
and place your connecting code into doInBackground(...)
.
EDIT: I did it like this:
FileOutputStream fos = activity.openFileOutput("temp.tmp", Context.MODE_PRIVATE);
System.out.println(activity.getFilesDir().getAbsolutePath());
client.enterLocalPassiveMode();
client.changeToParentDirectory();
client.changeWorkingDirectory("/dsct2c/" + username);
client.retrieveFile(filename, fos);
fos.close();
publishProgress(activity.getString(R.string.toast_file_saved) + " " + filename);
FileInputStream fis = activity.openFileInput("temp.tmp");
InputStreamReader isr = new InputStreamReader(fis);
BufferedReader br = new BufferedReader(isr);
String line = br.readLine();
while(line != null)
{
publishProgress(line);
System.out.println(line);
line = br.readLine();
}