Skip to content

Connect to sqlite db #420

@rainman-wf

Description

@rainman-wf

Hi! I spent a lot of time and effort to connect to the database using the Room library. What I need it for...
I need to get data from the group_messages and group tables in real time. The Room library allows me to do this using kotlin flow. This approach helps to get rid of unnecessary intermediate objects and code.

@Dao
interface MsgDao {

    @Query("SELECT * FROM group_messages")
    fun getAllMessages(): Flow<List<GroupMessage>>

    @Query("SELECT * FROM group_messages WHERE group_id = :groupId")
    fun getMessagesByConversationId(groupId: ByteArray) : Flow<List<GroupMessage>>

    @Query("SELECT * FROM groups")
    fun getAllConversations(): Flow<List<Group>>

}

I have achieved a stable connection and real-time data acquisition, but...

I found that no new messages are being added to the table. I've tried calling the sync() and syncAllConversations() methods, but even that doesn't update the data in the tables. I receive updated data only after restarting the application. I use the Room library in read only mode.
What needs to be done so that new data gets into the table dynamically?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions