How to Build a Notes App in Android Studio

In this tutorial, you will learn how to build a simple Notes App in Android Studio. This app allows users to create, update, delete, and view notes using a local database.

Features of Notes App

  • Add new notes
  • Edit existing notes
  • Delete notes
  • View all notes
  • Store data locally using SQLite or Room

Tools Required

  • Android Studio
  • Java or Kotlin
  • SQLite or Room Database
  • Basic UI Design (XML)

Project Setup

Create a new project in Android Studio and choose Empty Activity. Select your preferred language (Java/Kotlin).

Design Layout (XML)

XML
<EditText
    android:id="@+id/editTextNote"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="Enter note" />

<Button
    android:id="@+id/btnSave"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Save" />

Create Database Helper (SQLite - Java)

Java
public class DBHelper extends SQLiteOpenHelper {
    public DBHelper(Context context) {
        super(context, "NotesDB", null, 1);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("CREATE TABLE notes(id INTEGER PRIMARY KEY AUTOINCREMENT, content TEXT)");
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("DROP TABLE IF EXISTS notes");
        onCreate(db);
    }
}

Insert Note

Java
public void insertNote(String note) {
    SQLiteDatabase db = this.getWritableDatabase();
    ContentValues values = new ContentValues();
    values.put("content", note);
    db.insert("notes", null, values);
}

Display Notes

Java
public Cursor getNotes() {
    SQLiteDatabase db = this.getReadableDatabase();
    return db.rawQuery("SELECT * FROM notes", null);
}

Update Note

Java
public void updateNote(int id, String note) {
    SQLiteDatabase db = this.getWritableDatabase();
    ContentValues values = new ContentValues();
    values.put("content", note);
    db.update("notes", values, "id=?", new String[]{String.valueOf(id)});
}

Delete Note

Java
public void deleteNote(int id) {
    SQLiteDatabase db = this.getWritableDatabase();
    db.delete("notes", "id=?", new String[]{String.valueOf(id)});
}

Main Activity Logic

Java
btnSave.setOnClickListener(v -> {
    String note = editTextNote.getText().toString();
    dbHelper.insertNote(note);
    Toast.makeText(this, "Saved", Toast.LENGTH_SHORT).show();
});

Enhancements

  • Use RecyclerView to display notes
  • Add search functionality
  • Use Room Database for better architecture
  • Add dark mode support
  • Sync with cloud (Firebase)

Common Mistakes

  • Not closing database connections
  • Missing permissions
  • Improper UI handling
  • Not validating input
  • Ignoring lifecycle methods

Practice Exercises

  • Add title and description fields
  • Implement RecyclerView list
  • Add edit screen
  • Add search bar
  • Convert SQLite to Room

Conclusion

Building a Notes App helps you understand CRUD operations, local databases, and Android UI development. It is a great beginner project to strengthen your Android development skills.

Note: Note: Always test database operations to ensure data is saved and retrieved correctly.