Salman Roy
Salman Roy

Reputation: 575

How to upload file through FTP in Android

I want to upload xml file to through ftp from android sdcard folder, I'm trying this code to connect to ftp:

      FTPClient f = new FTPClient();
      f.connect(server,21);
      f.login(username,password);
      Log.d("status",f.getStatus());
      f.logout(); 
      f.disconnect();    

but I getting exception

Exception:

java.net.SocketException: Permission denied

Upvotes: 0

Views: 7350

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006779

Make sure you have requested the INTERNET permission in the AndroidManifest.xml file using a <uses-permission> element as shown below:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="apt.tutorial.two" android:versionCode="1" android:versionName="1.0">
    <uses-permission android:name="android.permission.INTERNET"/>
        <application android:label="@string/app_name">
                <activity android:name=".Patchy" android:label="@string/app_name">
                        <intent-filter>
                                <action android:name="android.intent.action.MAIN"/>
                                <category android:name="android.intent.category.LAUNCHER"/>
                        </intent-filter>
                </activity>
        </application>
  <supports-screens android:largeScreens="true" android:normalScreens="true" android:smallScreens="true" android:anyDensity="true"/>
</manifest>

Upvotes: 6

Related Questions