Android Notes App Using SQLite Database

Hey, Developers! In last tutorial we learned about the basic operation of CRUD in the SQLite Database using SQLiteOpenHelper class.

Now in this tutorial we're going to create a simple Notes App with SQLite as database storage. The app will be very minimal and will have only one screen to handle the notes.

At first, we will create android application. Then, we will see how to build Notes App in the application.

Follow steps below to create new project. Please ignore the steps if you have already created a new application.

S. No. Steps
1 Open Android Studio.
2 Click on Start a new Android Studio Project then choose your project and select Empty Activity.
3 Write application name as NotesApp after this write a package name you can write your own package name.
4 Select language Java. Select minimum SDK you need. However, we have selected 17 as minimum SDK. Then, click next button.
5 If you have followed above process correctly, you will get a newly created project successfully. However, you can also visit tutorial  to Create a New Project to know steps in detail.


Open build.gradle under the folder of the app and add RecyclerView dependency.

" implementation '' "

The RecyclerView will be used to show the notes in a list format. 

apply plugin: ''

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.ukacademe.notesapp"
        minSdkVersion 17
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner ""
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), ''

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation ''
    implementation ''
    implementation ''
    testImplementation 'junit:junit:4.12'
    androidTestImplementation ''
    androidTestImplementation ''

Click on res => values folder and open the color.xml file. And include the following code.

<?xml version="1.0" encoding="utf-8"?>
<color name="colorPrimary">#008577</color>
<color name="colorPrimaryDark">#00574B</color>
<color name="colorAccent">#D81B60</color>
<color name="msg_no_notes">#999</color>
<color name="hint_enter_note">#89c3c3c3</color>
<color name="timestamp">#858585</color>
<color name="note_list_text">#232323</color>

Click on res => values folder and open the dimens.xml file. And include the following code.

<?xml version="1.0" encoding="utf-8"?>
<dimen name="fab_margin">16dp</dimen>
<dimen name="activity_margin">16dp</dimen>
<dimen name="dot_margin_right">10dp</dimen>
<dimen name="msg_no_notes">26sp</dimen>
<dimen name="margin_top_no_notes">120dp</dimen>
<dimen name="lbl_new_note_title">20sp</dimen>
<dimen name="dimen_10">10dp</dimen>
<dimen name="input_new_note">20sp</dimen>
<dimen name="dot_height">30dp</dimen>
<dimen name="dot_text_size">40sp</dimen>
<dimen name="timestamp">14sp</dimen>
<dimen name="note_list_text">18sp</dimen>

Click on res => values folder and open strings.xml file. And include the following code. This file includes all the strings that the project uses. 

<string name="app_name">Notes App</string>
<string name="action_settings">Settings</string>
<string name="activity_title_home">Notes</string>
<string name="msg_no_notes">No notes found!</string>
<string name="lbl_new_note_title">New Note</string>
<string name="lbl_edit_note_title">Edit Note</string>
<string name="hint_enter_note">Enter your note!</string>

We need to build a class extending from SQLiteOpenHelper. This class performs CRUD activities (Create, Read, Update, and Delete) on the database.

In order to handle notes readily, we also need a model class to generate Note items.

Click on java => com.ukacademe.notesapp and create a package and write a name as model under this package create a class named In this class we define the SQLite table name, column names and create table SQL query along with getter / setter methods.

  • The 'notes' table needs three columns i.e 'id', 'note' and 'timestamp'.
  • Column 'id' is defined as Primary Key and Auto Increment which means each note will be uniquely identified by its id.
  • Column 'note' stores the actual note text.
  • Column 'timestamp' stores the date and time of the note that is created.

So open the class. And include the following code.

package com.ukacademe.notesapp.model;

public class Note {
    public static final String TABLE_NAME = "notes";

    public static final String COLUMN_ID = "id";
    public static final String COLUMN_NOTE = "note";
    public static final String COLUMN_TIMESTAMP = "timestamp";

    private int id;
    private String note;
    private String timestamp;

    // Create table SQL query
    public static final String CREATE_TABLE =
            "CREATE TABLE " + TABLE_NAME + "("
                    + COLUMN_NOTE + " TEXT,"
                    + ")";

    public Note() {

    public Note(int id, String note, String timestamp) { = id;
        this.note = note;
        this.timestamp = timestamp;

    public int getId() {
        return id;

    public String getNote() {
        return note;

    public void setNote(String note) {
        this.note = note;

    public String getTimestamp() {
        return timestamp;

    public void setId(int id) { = id;

    public void setTimestamp(String timestamp) {
        this.timestamp = timestamp;

Right click on model => DatabaseHelper create a class called under the model package and extend the SQLiteOpenHelper class. This class holds methods for performing CRUD operations related to the database.

  • onCreate() will only be called once upon installation of the app. In this technique, we perform the statements creating table sql to generate the tables needed.
  • onUpgrade() call upon the release of an update. To perform this technique, you must change the DATABASE VERSION. Here you need to take care of database migrations without losing the older information if needed. We're dropping the older tables for now and recreating them again.