-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using Room persistence library to access the database #108
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- build.gradle: Added room dependencies, added javaCompileOptions to export DB schema (schemas/org.secuso.privacyfriendlytodolist.model.database.TodoListDatabase/3.json) - Changes at model: - Hiding all classes behind interfaces - Kept model services as abstract as possible, tried to hide the SQL DB - Usage of room persistence library - Changed from DBQueryHandler to ModelServices to make use of new model General changes: - Fixed spelling: Renamed subTask to subtask - Used interface List instead of ArrayList where possible Current state of migration: It compiles but did not run. Open task: First tests and bug fixes. Optional: Create unit tests in development branch for old DB access method. Pull them into this branch and let them run against room implementation.
# Conflicts: # app/build.gradle
…hrows exception if called from main thread and tells that such actions should be done async from main thread to not freeze the UI. To solve that issue started to do DB access async: - Made work of ReminderService via WorkerManager async (ReminderWorker). - Create ViewModelServices to make DB access from UI classes async. Started at MainActivity. Delete translated texts which were used for log statements only because log statements were deleted.
…rence to parent activity as FragmentActivity reference. It gets used as context, ViewModelStoreOwner and LifecycleOwner.
- minSdkVersion 17 -> 19 to be able to change lifecycle-viewmodel-ktx:2.4.1 -> 2.7.0 - Changed from kotlin-kapt to KSP - Applied suggestion variant.outputs.all -> variant.outputs.configureEach build.gradle: - Applied suggestion to change repository jcenter() -> mavenCentral() - Applied suggestion task clean(type: Delete) -> tasks.register("clean", Delete) Major change: - Based on https://developer.android.com/training/data-storage/room/async-queries decided to use Coroutines (suspend) to implement asynchronous DB access - Created CustomViewModel for classes that do not implement ViewModelStoreOwner and therefore can't get LifecycleViewModel from ViewModelProvider - With that no separate worker for ReminderService is needed anymore. Merged ReminderService and ReminderWorker again - Created ResultConsumer interface as callback for coroutines - Changed ALL calls of data model to do subsequent actions in such a callback
Auto-organized imports.
…igrationTestHelper class to test migration.
Added DB migration from v1 to v2 to v3. Added DB migration tests.
… key to show that it does not belong to a list (DUMMY_LIST_ID = -3). But now with Room API this triggers an exception that foreign key constraint was not met. To solve this the foreign key of todo-tasks was changed from int to nullable int. null value does not trigger this exception. Bugs fixed: - At inserting into DB the new row ID now gets stored manually in the object. This is not done by room. - Task description was not stored at DB because shadow variable did exist. Now its removed.
…e as in the previous releases. Otherwise Room will not see old database and therefore will not start DB migration.
This was referenced Apr 12, 2024
Closed
Merged
This was referenced Dec 19, 2024
Merged
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Room persistence library makes database access and future database extensions easier.