Projects › Advanced
Android Habit Tracker
A native Android app to build habits with streaks, reminders, a home-screen widget and offline storage.
Level: Advanced · Time: 2–3 weeks · Tech stack: Kotlin, Jetpack Compose, Room, WorkManager
Features to build
- Create daily/weekly habits with goals
- One-tap check-in and streak counting
- Reminder notifications at chosen times
- Calendar heatmap and statistics
- Works fully offline (Room database)
What you will learn
- Kotlin and Jetpack Compose
- MVVM with ViewModel and Flow
- Room database
- Background work and notifications
Step-by-step guide
1. Architecture: MVVM
UI (Compose) → ViewModel (state as StateFlow) → Repository → Room DAO. The UI only observes state.
2. Room
@Entity data class Habit(@PrimaryKey(autoGenerate = true) val id: Long = 0, val name: String, val target: Int, val reminder: String?)
@Entity(primaryKeys = ["habitId", "day"]) data class CheckIn(val habitId: Long, val day: String)
@Dao interface HabitDao {
@Query("SELECT * FROM Habit") fun habits(): Flow<List<Habit>>
@Insert(onConflict = OnConflictStrategy.IGNORE) suspend fun checkIn(c: CheckIn)
}
The composite primary key stops double check-ins on the same day.
3. Streaks
Walk back from today over the check-in days until a gap — compute it in the repository and expose it in the UI state.
4. Reminders
Schedule a periodic WorkManager job per habit; post a notification (ask for the POST_NOTIFICATIONS permission on Android 13+).
5. Stats
A Compose canvas heatmap for the last 12 weeks and completion percentages.
6. Ship it
Material 3 theming with dark mode, then publish an internal test on the Play Console (or share the APK).
Level it up
- Home-screen widget with Glance
- Cloud backup with Firebase
- Share streak cards
On your resume
- Built a native Android habit tracker in Kotlin (Jetpack Compose, MVVM, Room, WorkManager) with streaks, reminders, statistics and full offline support.