How to Connect Android with PHP, MySQL - Android Studio 2015

submitted by Ching Yang on 02/13/16 1

How to Connect Android with PHP, MySQL - Android Studio 2015 Download the lib at github.com/kosalgeek/generic_asynctask 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. 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 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: www.kosalgeek.com/2015/09/tired-of-re-creating-asynctask-classes.html Visit my blog: www.top12review.com You can follow me: twitter.com/okosal Subscribe. Like. Share. Comment. Photo Credit: The photo (www.flickr.com/photos/janitors/21027307169) used in my video cover is copyright (c) by Kārlis Dambrāns (www.flickr.com/photos/janitors/) made it available under Creative Commons (creativecommons.org/licenses/by/2.0/).

Leave a comment

Be the first to comment

Email
Message
×
Embed video on a website or blog
Width
px
Height
px
×
Join Huzzaz
Start collecting all your favorite videos
×
Log in
Join Huzzaz

facebook login
×
Retrieve username and password
Name
Enter your email address to retrieve your username and password
(Check your spam folder if you don't find it in your inbox)

×