Friday, December 30, 2016

Android Populating Spinner Data From SQLite Database



In previous tutorial i also created CRUD (Create, Read, Update, Delete) function using database SQLite. On that tutorial there is a condition where the data must be displayed on spinner.

If you are newbie in Android, it my previous tutorial maybe too complicated for you to get which point is actually the spinner function.

To make you easy understand the process, so i creating this tutorial, especially how to populating spinner data from SQLite.

If you need to go through to the CRUD tutorial, you can read here : Android SQLite Database Tutorial

Let's start created this tutorial. As always a provide you a video demo in order you get what the output of this tutorial.

VIDEO DEMO



IMPLEMENTATION

First, create model of your data, in this case i name my model as OwnerModel.java, then paste the following code :

Second, create java class that called DatabaseHandler.java. Paste the following code :

Attention :
In code above we define all the main function of CRUD, the query, or anything that related with database. I Have explained this class on previous tutorial here : Android SQLite Database Tutorial

Third, create MainActivity's layout. Usually, the name is always activity_main.xml. After that paste the following xml code :

Fourth, In your MainActivity.java will do much technical process like, input the data, display data to spinner and clear/delete all data from SQLite database. Paste the following code :

Run your project, hope it works well. Thank you.

Related Posts

1 komentar so far


EmoticonEmoticon