Android PHP MySQL tutorial. How to Insert to MySQL From Editext, CheckBox and Spinner, then Select and show in ListView.


Today we want to explore how to save several data types into MySQL database from our android application.We want to save boolean and strings to mysql database.The components acting as our input views include edittext,spinner and checkbox .We have a fictional spacecraft with a String property name,String property propellant as well as boolean/integer property ‘does technology exist’;

MySQL Insert From CheckBox,Spinner

What we do :

  • User types into EditText,Selects from spinner and checks/unchecks the checkbox.
  • We fetch this data and make a HTTP POST request to the server.
  • Our MySQL database is hosted locally in localhost.
  • The request happens in the background thread.
  • We are returned a response depending on the success or failure of the operation.
  • If successfull we reset our input views.
  • We are using Android Networking library by Amit Shekhar.

Common Questions we answer :

  • Save Boolean to MySQL database.
  • Save Integers or String to MySQL database.
  • Map Boolean to Integers.
  • Save From Android to MySQL.
  • HTTP POST method.
  • Background thread Android Networking.
  • Save.Insert from spinner,from checkbox,from editext.
  • PHP MySQL JSON Android.
  • Object Oriented PHP MySQL database.

What You’ll do :

  • Create a project in android studio.
  • Give it a name and choose minimum and target SDKs.
  • Add permission for internet connection in your android manifest.
  • Add a dependency statement for a networking library we’ll use.
  • Create a MySQL table and write some PHP code.
  • Run your project.
  • I tested mine in bluestacks emulator.

Overview :


  1. MainActivity class
  2. Spacecraft class
  3. MySQLClient class.


  1. ActivityMain.xml
  2. ContentMain.xml


  1. Add Permission for Internet


  1. Part 1 – Introduction.
  2. Part 2 – Java Code
  3. Part 3 – XML Layouts.
  4. Part 4 – PHP Code

    Direct Download