How to create Directory on server in Java Android

How to create Directory on server in Java Android
April 7, 2020 No Comments Android Development,Development Pushpendra Kumar

Hi Guys, Welcome to the new trick. Here you learn How to create Directory on server in Java Android. Here I have took a basic example of a directory. In other word, I will tell you the very sort trick for uploading the big data on the server without api interaction.

Create Directory on server in Java Android

So let’s begin with the practical programming. This technique really will save your life if you are working on the big application and you are worried about server hanging issue. Then go through with this technique. At the very first we will create a directory on the server. So let’s begin with the step by step.

  • Create a New Android Application – If you did not have your own code!
  • Download a JAR Library from the given link
  • Add unzip the file and copy file inside your libs folder. which is as – application_root_folder -> app->libs
  • Now add dependency in your android project.
  • Open Project Structure, Click on File. After that you will see project structure, open that.
  • Now click on Dependency and do as mention in below image.
  • how to create directory in java
  • Click on Dependency -> Click on App -> + button below declared dependency.
  • Select Jar file and then check apache-commons-net
  • how to create directory in java android
  • All right you have done almost. Now click on DONE after that Apply and after that OK

Now it’s time for coding 😎😎😎😎

Add Internet permission to your AndroidManifest.xml file.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=""

    <uses-permission android:name="android.permission.INTERNET" />

        <activity android:name=".MainActivity">
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />


Great.. 👍 

Now we code into Java. And your java file looks like that.

import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;


public class MainActivity extends AppCompatActivity {

    protected void onCreate(Bundle savedInstanceState) {
        new CreateDir().execute();

    static class CreateDir extends AsyncTask<Void, Void, Void> {
        String TAG = "MAIN_ACTIVITY";

        protected Void doInBackground(Void... voids) {

            String server = "XXX.XX.XX.XXX"; // YOUR IP ADDRESS OR DOMAIN NAME EX - OR
            String username = "XXXXXXXXXXXXXX"; // Your ftp username EX - root OR Ubuntu or XYZ
            String password = "XXXXXXXXXXXXXXXX"; // Your ftp password EX - NCSJN123 OR *#&YBSUSDN

            FTPClient ftpClient = new FTPClient();
            try {
                ftpClient.login(username, password);

                Log.d(TAG, "CONNECTED");

                String dirPath = "/public_html/upload_files/new_dir";
                boolean created = ftpClient.makeDirectory(dirPath);

                Log.d(TAG, String.valueOf(created));


                Log.d(TAG, "DISCONNECTED");
            } catch (Exception e) {
            return null;

😎 😎😎 COOL 😎😎😎😎 

NOTE * – If you are facing any issue something like permission denied or Host name is not associated. Then Uninstall your application first and again install. But make sure you follow the complete tutorial as per suggestion.

In Conclusion, You have done with all the functionality. But if still you are facing any issue then you can watch the complete video here.

About The Author
Pushpendra Kumar I am passionate about mobile application development and professional developer at Colour Moon Technologies Pvt Ltd ( This website I have made so that I can meet with new challenges and can share here.

Leave a reply

Your email address will not be published. Required fields are marked *