Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7308465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T23:33:39+00:00 2026-05-28T23:33:39+00:00

I recently just started on Android Application development. My application requires me to connect

  • 0

I recently just started on Android Application development.
My application requires me to connect to a MySQL database. Therefore I’m using a FTP server to store my PHP files. In order to access the database, the application on the android phone has to be connected to the FTP server.

I’m trying to connect to the ftp server, however the app throws:

java.lang.IllegalStateException:Scheme ‘ftp’ not registered

package com.example.login2;

import java.util.ArrayList;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import android.util.Log;
import org.apache.commons.net.ftp.*;


public class login2 extends Activity {
EditText un,pw;
TextView error;
Button ok;
public boolean mConnect;
public FTPClient mFTPClient = null;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    un=(EditText)findViewById(R.id.et_un);
    pw=(EditText)findViewById(R.id.et_pw);
    ok=(Button)findViewById(R.id.btn_login);
    error=(TextView)findViewById(R.id.tv_error);

    ok.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            mConnect = ftpConnect("ftp.example.comule.com", "name","passwordxxx", 21);
            ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>();
            postParameters.add(new BasicNameValuePair("username", un.getText().toString()));
            postParameters.add(new BasicNameValuePair("password", pw.getText().toString()));
            //String valid = "1";
            String response = null;
            try {
                response = CustomHttpClient.executeHttpPost("ftp://a5021174@matthewkee.comule.com/footprint/login.php", postParameters);
                String res=response.toString();
               // res = res.trim();
                res= res.replaceAll("\\s+","");                              
                //error.setText(res);

               if(res.equals("1"))
                    error.setText("Correct Username or Password");
                else
                    error.setText("Sorry!! Incorrect Username or Password"); 
            } catch (Exception e) {
                un.setText(e.toString());
            }
        }
    });
}

public boolean ftpConnect(String host, String username, String password, int port)
{
    try {
        mFTPClient = new FTPClient();
        // connecting to the host
        try{
            mFTPClient.connect(host, port);
        }catch(Exception e)
        {
            Toast toast1 = Toast.makeText(getApplicationContext(), "This is the exception thrown: "+e, 1000000);
            toast1.show();
        }

        // now check the reply code, if positive mean connection success
        if (FTPReply.isPositiveCompletion(mFTPClient.getReplyCode())) {
            // login using username & password
        boolean status = mFTPClient.login(username, password);

        //toast.show();

        /* Set File Transfer Mode
        *
        * To avoid corruption issue you must specified a correct
        * transfer mode, such as ASCII_FILE_TYPE, BINARY_FILE_TYPE,
        * EBCDIC_FILE_TYPE .etc. Here, I use BINARY_FILE_TYPE
        * for transferring text, image, and compressed files.
        */
        mFTPClient.setFileType(FTP.BINARY_FILE_TYPE);
        mFTPClient.enterLocalPassiveMode();

        return status;
    }
    } catch(Exception e) {
         Log.d("ftpConnectApp", "Error: could not connect to host " + host);
    }
    return false;
    }

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T23:33:40+00:00Added an answer on May 28, 2026 at 11:33 pm

    You are trying to do a Http request using HttpPost class on a FTP server. Try using classic Url connection to your FTP server, it should solve your issue. I found you 2 tutorials to give you some pointers :

    File upload
    How to upload a file using FTP

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just recently started using Mono for Android and I am trying to consume
I recently started using android actionbars and contextual action bars (CAB). I have just
I just recently started using Hudson as a CI server for a project of
I just recently started working on a database-heavy Clojure application and am attempting to
I'm using SQL Server 2008 and just recently started having an intermittent problem while
I recently started working on a large complex application, and I've just been assigned
I just recently started using this library (the one from CodePlex), but I ran
I have just recently started out programming for Android, and have decided that I
I just recently started using Jinja2 for HTML templating on Google App Engine and
I just recently started with object oriented programming, using java. Before I was programming

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.