Home > Back-end >  Should I always perform database operation in a separate thread in android?
Should I always perform database operation in a separate thread in android?

Time:09-17

Performing sqlite database operations in android is slowing down my application but what would be a good way to remove that sluggishness? shold I just perform database operations on a seperate thread or is there any other more suitable way?

CodePudding user response:

Exactly, you should. If you use Room, it will help you greatly with that as it support livedata/flow, and you can just watch from your fragments, and it will not perform database operation in the main thread.

what is room: https://developer.android.com/training/data-storage/room

Google codelab to help you get going: https://developer.android.com/codelabs/android-room-with-a-view-kotlin#0

  • Related