Documentation Index
Fetch the complete documentation index at: https://mintlify.com/apursley2012/PunctuOwlity/llms.txt
Use this file to discover all available pages before exploring further.
DatabaseHelper extends SQLiteOpenHelper and is the single point of access for all persistent data in the PunctuOwlity Android app. It manages punctuowlity.db (version 1) and exposes separate method groups for user account management and event CRUD operations. Every Activity that needs database access instantiates DatabaseHelper directly by passing the Android Context to its constructor.
Database Schema
The database contains two tables created inonCreate. Both are created with INTEGER PRIMARY KEY AUTOINCREMENT surrogate keys.
The
username column in the users table carries a UNIQUE constraint. Attempting to insert a duplicate username returns -1 from db.insert(), which causes insertUser to return false.User Methods
These methods handle account creation and credential verification forLoginActivity and SignupActivity.
insertUser
users table using ContentValues. Returns false if the insert fails — most commonly because username already exists (enforced by the UNIQUE constraint).
The account username. Must be unique across all rows in the
users table.The account password stored as plain text.
true if the row was inserted successfully (db.insert() returned a row ID ≥ 0); false if the insert failed.
checkUser
users table for a row matching both username and password. Used by LoginActivity to validate credentials before navigating to MainActivity.
The username to look up.
The password to verify against the stored value.
true if at least one matching row exists (cursor.getCount() > 0); false otherwise. The cursor is always closed before returning.
Event Methods
These methods manage the full lifecycle of events displayed inMainActivity and edited via AddEventActivity.
insertEvent
events table. The id is assigned automatically by SQLite’s AUTOINCREMENT.
The event name, e.g.
"Dentist".The event date in
MM/dd/yyyy format, e.g. "04/14/2025".The display time string, e.g.
"01:30PM" or "ALL DAY".true if the row was inserted successfully; false otherwise.
updateEvent
title, date, and time columns of the events row identified by id. Uses db.update() with COL_EVENT_ID + "=?" as the WHERE clause.
The SQLite row ID of the event to update.
The new event title.
The new date in
MM/dd/yyyy format.The new display time string.
true if at least one row was affected (db.update() returned > 0); false if no row matched the given id.
deleteEvent
events row with the matching id. Called from MainActivity when the user taps the delete button on an event card.
The SQLite row ID of the event to delete.
true if at least one row was deleted; false if no row matched.
getAllEvents
SELECT * FROM events and maps every row to an Event(id, title, date, time) instance. Called by MainActivity.loadEvents() on onCreate and onResume.
Returns: An ArrayList<Event> containing all stored events in their natural insertion order. Returns an empty list (not null) if the table is empty.
getEventById
events table for a single row by primary key. Used by AddEventActivity when launched with an "event_id" extra to pre-populate the edit form.
The SQLite row ID of the event to retrieve.
Event(id, title, date, time) instance if a matching row is found; null if no row exists for the given id. Callers must null-check the return value.
Upgrade Behavior
When the database version is incremented,onUpgrade drops both tables and recreates them by calling onCreate: