Android Login and Register Using Restful Web Services (Java + MySQL)

Here you will learn to make android login and register system using restful web services in java and mysql.

In this tutorial I will teach you to develop a very simple android app for login and register system. This system sends the login or register request to the restful web service that is running on local server.

If you don’t know how to make restful web services in java and use it in android then I would highly recommend you to first read below tutorials.

Also Read: Create Simple Java RESTful Web Services Using Jersey

Also Read: Android Restful Web Service Client Example

Android Login and Register Using Restful Web Services (Java + MySQL)

Android Login and Register Using Restful Web Services (Java + MySQL)

Create Restful Web Service

I have used MySQL database in this web service. Make a login table in database with following schema.

mysql database login schema

 

Below is the code for restful web service developed in Java.

DemoService.java

 

Create Android Project

Make a new android project with package name com.loginandregister

For sending and fetching data from server I am using Volley library. So add its dependency in build.gradle file.

 

Read below tutorial if you don’t know how to use volley library.

Also Read: Android Volley Tutorial With Example

 

As we are doing network related operation so add internet access permission in AndroidManifest.xml file.

 

Now create three activities in the project Login, Register and Home. Add following code in the respective files.

Login.java

 

activity_login.xml

 

Register.java

 

activity_register.xml

 

Home.java

 

activity_home.xml

 

Make sure the web service is already running on the server. Also change the IP 192.168.1.8 in the URL with the IPv4 of your local system. You can find the IPv4 in windows by typing ipconfig command in command prompt.

Finally run and test the project.

 

Screenshots

login

register

home

 

The whole code is very simple and self-explanatory. If still you are facing any problem then feel free to ask in comment section.

2 thoughts on “Android Login and Register Using Restful Web Services (Java + MySQL)

  1. Pushkar Zagade

    Hay,
    The Above code are not able to connect to database. It Show com.android.volly.NoConnectionError java.net.connectException failed to connect to 127.0.0.1. It Show exception in emulator with Toast.

    Reply

Leave a Reply

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