SQLite Create Database and Tables

creating-database-and-tables-sqlite-android-thumb

In this tutorial we will be looking at how to create a SQLite Database and Table using Android Studio.

Before staring we will be looking at how the interface will look like

Here is the interface that we will be building in this entire tutorial series

sqlite-database

Step 1 :

Create a new Android Studio Project. Name it as per you convention. After the project has been created successfully open the activity_main.xml file and paste in the code from below.

Step 2:

Create a DBHandler file which will contain the entire database code. For this go to java folder, right click and add new class file and name it DBHandler

Paste the code from below into your code. You can change the name of the table. Make sure that the DBHandler constructor remains the same. In the onCreate method we create the table. So over here you can create as many table as you want, just type in different queries and execute it. And lastly the onUpgrade method will fire whenever the database is updated that is when new tables or fields are added.

 

 

 

 

One thought on “SQLite Create Database and Tables

Leave a Reply

Your email address will not be published. Required fields are marked *