Android SQLite Database Tutorial (Select, Insert, Update, Delete)




SQLite is an open-source social database i.e. used to perform database operations on android gadgets, for example, putting away, controlling or recovering relentless information from the database.

It is implanted in android bydefault. In this way, there is no compelling reason to play out any database setup or organization assignment.
Here, we are going to see the case of sqlite to store and get the information. Information is shown in the logcat. For showing information on the spinner or listview, move to the following page. SQLiteOpenHelper class gives the usefulness to utilize the SQLite database.

A Simple Android SQLite Example
So lets create a project.

Step 1  – Create new Android project.

Provide Activity name as SQLiteApp as shown below

Android SQLite Database Tutorial
Android SQLite Database Tutorial . Create Project

 

Step 2 – Add components in the main activity as shown in the picture below.

 

Android SQLite Database Tutorial. Design Activity
Android SQLite Database Tutorial. Design Activity

\AndroidStudioProjects\SqliteApp\app\src\main\res\layout\activity_main.xml

 

Step 3 – Now create a new Java class called DatabaseHelper.java.

Android SQLite Database Tutorial. DatabaseHelper
Android SQLite Database Tutorial. DatabaseHelper

Add the following code in this class to DatabaseHelper.java

MainActivity.java

OUTPUT

Android SQLite Database Tutorial. Add Data
Android SQLite Database Tutorial. Add Data
Android SQLite Database Tutorial. Data Successfully added to sqlite database
Android SQLite Database Tutorial. Data Successfully added to sqlite database

 

Android SQLite Database Tutorial. View Data
Android SQLite Database Tutorial. View Data

 


Partner Sites

VideoToGifs.com

EasyOnlineConverter.com

SqliteTutorials.com


  • utsav

    it is showing 2 errors…
    1.cannot find symbol variable menu
    2.cannot find symbol variable action_settings

    • SlovakianProgrammer

      Same error .

    • Abdallahi

      I have commented those 2 methods including menu variable and action_Setting and it gose well 🙂

  • adnan

    very helpful videos and code.. thank you buddy 🙂

  • thank you for the video + the code.

  • Fajar Rahmadi

    Nice tutorial, but where code for menu_main.xml ?

    • bunga

      i need the answer for this question also

  • maksood

    THIS APP IS CLOSING AFTER CLICKING ON ADD BUTTON, WHY it only says
    “Unfortunately app has stopped” please help me

    • pao david

      Mee Too