Loading...

How to Connect Android with PHP, MySQL ☎️ Best Android Studio Tutorial ☎️ ANDROID PHONE

How to Connect Android with PHP, MySQL ☎️ Best Android Studio Tutorial ☎️ ANDROID PHONE
Best Android Studio Tutorial on How to Connect Android with PHP, MySQL (PhpMyAdmin) XAMPP. Please subscribe https://youtube.com/oumsaokosal?sub_confirmation=1

To connect Android with MySQL Database, you cannot do it directly. You need a Web service as a medium. In this case, we can use PHP because in PHP you can have a single of code that easily converts database data into the JSON format. You can convert it to XML as well, but many prefers JSON due to its size and performance. 

Best Android Studio Tutorial - How to Connect Android with PHP, MySQL
Check out my new video at https://www.youtube.com/watch?v=5v_1cqkFSuQ

This is another updated video about Android Volley: https://www.youtube.com/watch?v=OaWm0jORpKs&list=PL0DVoqvV_Tdhv5SziqTgGTBBsg2Mu6XvF

Download the lib at https://github.com/kosalgeek/generic_asynctask

You can learn Android Volley at https://www.youtube.com/playlist?list=PL0DVoqvV_Tdhv5SziqTgGTBBsg2Mu6XvF

Android recently changed its IDE from Eclipse-based Android Development Toolkit (ADT) to IntelliJ IDEA-based Android Studio. The big reason for that is Gradle. Gradle is a modern open source build automation system. It works better in many ways than Ant, which is used by Eclipse-based Android IDE. The change also affects some old APIs to deprecate.

In this tutorial "How to Connect Android with PHP, MySQL", l uses the new IDE, Android Studio along with the new APIs. Moreover, I created my own library that simplified the way of how to connect Android with PHP and MySQL. Before this, you had to have a private class extends AsyncTask class all the time in order to connect to the Web. The AsyncTask class works as background thread. Since Android 3.0 API 11 (Honeycombs), you are allowed to use the main thread to do a long process, such as connecting to Web. I named the lib as GenAsync.jar (Generic AsyncTask) and you can download it at https://github.com/kosalgeek/generic_asynctask. My lib hides all the complexity and all you have to do to instantiate the PostResponseAsyncTask class and pass a POST data as a second argument of the constructor. You call the execute() method and provide the URL that you want to pass the data to. Finally, you can receive the data by processFinish() method. This course guides how to create a database and a table in MySQL and create PHP pages.

Recommended to Read this post to understand more about my library: 
http://kosalgeek.com/connect-android-php-mysql-generic-asynctask

Check out the latest articles on Android Phone at:
https://kosalgeek.com

Subscribe. Like. Share. Comment.

Oum Saokosal

Photo Credit: 
The photo (https://www.flickr.com/photos/janitors/21027307169) used in my video cover is copyright (c) by Kārlis Dambrāns (https://www.flickr.com/photos/janitors/) made it available under Creative Commons (https://creativecommons.org/licenses/by/2.0/).

RRelated Posts

CComments

  • rhea butala
    How can i read data from database if login id and pasaword are valid and display it in the next activity in ?
  • khaing pho
    Thank for your sharing the useful tutorial!
  • Sandeep Mathur
    sir when sending post data to my local server then the result in processFinish is empty.....help me
  • Archana Soyjaudah
    Thank you Sir! :-)
  • Rushabh Buch
    Can we use the same code if we want to test in on a real android device and not on emulator
  • Waleed Ahmad
    Hi Oum, can i connect livePHPMYSQL with webview
  • Bhargav Mehta
    Pls remove noise it's terrible. Upload video again
  • ҭђἔ łᾄṩҭ ṩἔмἷƈὄłὄᾗ
    awesoOoOoOome great thx!
  • Bosch Pharma
    GOOD TUTORIAL.. i want connect android with oracle database. how can i do.. can u plz help me ....
  • Jenish Parmar
    error in line no 12 solve pleash
  • Jennifer Flynn
    When I create an instance of PostResponseAsyncTask it says it is deprecated . PostResponseAsyncTask task = new PostResponseAsyncTask(this); is what i typed. Error is: it is deprecated. Can someone tell me how to fix this please
  • little programmer
    how can i get your source code ?
  • patel vaibhavee
    Sir apne xmap me htdocs use kya vese ham wampserver me kya use kre ne ge?
  • little programmer
    what is the different between using jdbc and php connection and please which one is better ?
  • SK SURAJ
    I want the login from android login activity but when he aproved then he will land the website in a webView into another activity. Please show how to do that, I really need that idea. I am searching for a long time but cant find out!
  • Adenilson Silva
    hello, I'm having problem with php error, isset, could you help me?
    Parse error: syntax error, unexpected T_ISSET, expecting T_STRING or T_VARIABLE or '$' in
    RESPONDER
  • Adenilson Silva
    ola, estou com problema com erro no php, isset, poderia me ajudar?

    Parse error: syntax error, unexpected T_ISSET, expecting T_STRING or T_VARIABLE or '$' in
  • Anurag Singh
    sir i am facing with a problem when i run my login.php it,s show a error "Parse error: syntax error, unexpected end of file in C:\xampp\htdocs\client\login.php on line 36"
    and my code is this
    <?PHP
    include_once("connection.php");
    if( isset($_POST['txtUsername']) && isset($_POST['txtPassword']) ) {
    $username = $_POST['txtUsername'];
    $password = $_POST['txtPassword'];

    $query = "SELECT username, password FROM tbl_client ".
    " WHERE username = '$username' AND password = '$password'";

    $result = mysqli_query($conn, $query);

    if($result->num_rows > 0){
    if(isset($_POST['mobile']) && $_POST['mobile'] == "android"){
    echo "success";
    exit;
    }

    else{
    echo "Login Failed <br/>";
    }

    }

    ?>
    <html>
    <head><title>Login|KosalGeek</title></head>
    <body>
    <h1>Login Example|<a href=”http://www.google.com”>Anurag</a></h1>
    <form action="<?PHP $_PHP_SELF ?>" method="post">
    Username <input type="text" name="txtUsername" value="" /><br/>
    Password <input type="password" name="txtPassword" value="" /><br/>
    <input type="submit" name="btnSubmit" value="Login"/>
    </form>
    </body>
    </html>
  • Umer farooq
    That was really helpful but i can't manage to configure out your php script, it dos't event work on web for test, 2nd is i only get the a little long toast not any rough php/html data.
    what i'm supposed to do to get rid of this.
  • Andre Heuer
    I don't get my light bulb red, but it is okay, if i just implement your class?
  • Daniela Radcliffe
    Hi Do you have a tutorial to connect Android Studio with postgresql?
  • MD RATAN HOSSAIN
    Thank you so much. I really got your php db connection helpful. Can I get video for signup.
  • Madhuri Gurav
    I have problems client is not ready yet please give me solution
  • Mm Gho
    how to make app to store data not for log in ...like users save their names and their age then all users can search for a specific age to get all the names
  • KDV Shared
    thanx,, its simple...
  • Areeba Shaikh
    i am getting my html code as response in log...but without success or something liked failed..
    just the form that i created for php :( can anyone help me please
  • Учитель Литературы
    A? My names is... A? My names.... TUtutu
  • Anurag Biswas
    when i try to enter parameters inside PostResponseAsyncTask()
    it strikes the PostResponseAsyncTask() and says it has been deprecated.
  • M G Shahriar
    i want to implement website login registration in Android app?? how i do that one database for web and mobile
  • Kirbi Timur Nomas
    gimana caranya buat koneksikan aplikasi android dgnn codeigniter sql tapi bukan localhost pak, via internet caranya gmn yah ?
  • Christian jay Bringino
    Hi, I need help about the GenAsync library.. when I type PostResponseAsyncTask task = new PostResponseAsyncTask(this); <--- it says that the new "PostResponseAsyncTask" is deprecated.. I don't know what to do next... I need help
  • Che Mohamad Firdaus Che Saidi
    Subscribed you ! Your videos help me a lot. Thank you 😊
  • Anyone can
    thankyou very much
  • Sally Morris
    I cant see the blog on the website and therefore i cant get the code
  • mugumya martin
    The database doesn't seem to connect to my device
    I'm using Leapdroid as my emulator
  • damodar punugubati
    please give me your mail id
  • damodar punugubati
    hi sir Thanks a lot ..............its very easy to understand ....im trying from 25days but I didn't ....today I got the result thanks a lot
  • AKHILA K
    PostResponseAsyncTask task = new PostResponseAsyncTask(this,postData);

    postData is came in red again sir! what to do now???

    i selected the red bulb and implemented, the error was gone , but after running the app, and after giving username and password after clicking login , it says unfortunately stopped
    i used http://localhost/client/login.php to run the app in my android mobile phn..
    please help sir....
  • AKHILA K
    PostResponseAsyncTask task = new PostResponseAsyncTask(this);

    while touching "this" im getting yellow light, but not red light! please help me sir..!!!
  • Areeba Shaikh
    ohh great!!! i was trying to do this since last one month...sir u are great :) (Y)
  • Fajar Ramadhan
    i want ask sir .. if i already download getasynctask .. and i installing with cmd (win7) , what next step ?

    cause my coding (login.php) is error ... preview is japanase or chinnese languange ..

    but if i just take html coding .. its normal (work)

    please give the solution
  • kuldeep negi
    please can u tell me how to access a specific function of web api inside my android program?

    if(service==washing)
    then it should fetch the data for me according to api.

    how can i use it un my program?
  • Razor Dkesh
    Hello sir thanx for great tutorial . and i connect to database successfully but the problem is that when i access data base from outside network (other wifi) then it cannot be accessed please help me??
  • Nesrine Kréchiche
    hello,
    by using the button ,html code appears as you but without "success " of php
    is the application connected or no if no what is the solution !??
  • Mian Kamran Manzoor
    hello sir i'm testing my app on my cell phone, so what should be the "localhost" replacement for me ? kindly help.. thanks
  • George Nuamah
    PostResponseAsyncTask(this);

    Cannot resolve constructor'PostResponseAsyncTask'...

    Nothing seem to work. Help for rookie needed. Thanks.
  • ditha satria
    Sir, How to select and show data to android with textview?
  • Sara Muggo
    Facing an error on login successful and failed in android emulator.It always show me login failed can u give solution to my problem???
  • anupam tripathi
    this application gives error on compiling says javascript is not enabled in a html page plz help
  • Joann May cruz
    every time i'll log in.. it's Log in failed. why?