Android MySQL - Insert From EditText,CheckBox,Spinner - Part 1 \[Introduction\]

| Page Views: 651 android networking

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

How do You Feel after reading this?

According to scientists, we humans have 8 primary innate emotions: joy, acceptance, fear, surprise, sadness, disgust, anger, and anticipation. Feel free to tell us how you feel about this article using these emotes or via the comment section.

About Me.

After completing his Software Engineering bachelors program, Oclemy(Clement Ochieng) these days is a man of two lives. At day he works for a startup in Nairobi, Kenya. At night he works tirelessly on building ProgrammingWizards TV, a tv channel for student coders and this website to help share the source code. In between he practices Meditation and Self actualization to help him keep balance. He also likes going for long solo walks to connect more with nature.


What do You Think

Previous Post Next Post