SQLite In Android Studio Simple Example Step By Step

Hello, developers. Welcome to SQLite In Android Studio Example.

This SQLite In Android tutorial will cover the simple operation of SQLite databases like insert and display data.

SQLite In Android tutorial is mainly targeted towards beginners with source code to download.

If you want to do all crud operations (insert, update, delete, display) with multiple table, then visit SQLite with multiple tables android

If you want to do all crud operations with one table, then visit Crud Operations In SQLite in Android.

First, check the output of SQLite In Android Studio example, then we will develop it.

How to get maximum benefit from SQLite In Android Studio example

Download Source Code

Try Our App

Download DemoNuts app to learn anytime, anywhere: Click to get demonuts app

Or search “demonuts” in play store from android mobile device.

Creating SQLite In Android Studio Tutorial step by step

If you are using adblocker, then you will not be able to show our site smoothly. For example, you find step 6 after step 1 or similar to this. So please disable adblocker to fully utilize all resources of DemoNuts

Step 1: Create a new project in Android Studio.

Step 2: Creating DatabaseHelper class

Create a new class named “DatabaseHelper” and all below source code

Step 3: Description of DatabaseHelper

Database name, Database version, table name and column names of tables are written as below.

Understanding most important part of SQLite Database

In onCreate() method, create statement for the table is written.

In onUpgrade() method, already exist tables are dropped and then all tables are recreated.

onCreate() method is called within onUpgrade() method to create tables.

In following scenarios, you need to upgrade DATABASE_VERSION number in increment order.

  1. When you add, update or delete any column of any table in the whole database.
  2. When you update any column name of any table.
  3. When you add, update or delete any table.
  4. When you update table name.

When DATABASE_VERSION is updated in increment order, onUpgrade() method is called.

addStudentDetail() method will add name to database.

getAllStudentsList() method will fetch all values of names from database.

Step 5: Updating activity_main.xml

Put following code in activity_main.xml

Step 6: Updating MainActivity.java

Add following  in MainActivity.java

When the user clicks on store button, the entered text is stored in the database as below.

When a user clicks on the getall button, all the names are fetched from the database.

For all crud operations (insert, update, delete, display) visit this: Crud Operations In SQLite In Android  

How to get exact Android example while searching in Google

Click to get Important Google searching tips

So that is all for SQLite in Android example.

Feel free to comment your queries and reviews in the comment section. Thank you 🙂


Hardik Parsania

I am mobile app developer. I am always passionate about solving complex and real world problems.I have developed many apps with great interest and superior logical skills.

You may also like...

2 Responses

  1. Moazzem says:

    Where is the student_database.bd file?

Leave a Reply

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