Hassam Ullah
Hassam Ullah

Reputation: 99

Should I always perform database operation in a separate thread in android?

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?

Upvotes: 1

Views: 427

Answers (1)

Henrique Vasconcellos
Henrique Vasconcellos

Reputation: 1183

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

Upvotes: 2

Related Questions