Migrate Persistence Layer from JSON Files to Room Database #2
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
The current implementation relies on manual JSON file I/O for data persistence. This approach is becoming difficult to maintain, lacks thread safety, and does not support complex queries or indexing.
We need to migrate the storage engine to Room (SQLite) to improve performance, data integrity, and to leverage structured data observation (Flow/LiveData).
Technical Implementation Plan
Add androidx.room dependencies to app/build.gradle.
Configure KSP (Kotlin Symbol Processing) for annotation handling.
Define the Database version (starting at 1).
Convert existing JSON data models into Room @Entity classes.
Implement @Dao (Data Access Objects) for CRUD operations.
Create the @Database abstract class to provide the singleton instance.
Update the Repository Pattern to inject the new DAO.
Replace manual file-parsing logic with Room query calls.
(Optional) Expose data as Flow for reactive UI updates.