Afzal Najam01/17/2022, 11:38 PM
, I close the database. When they return, I use the Navigation component to direct them to the Password Screen. The screen with the list of data uses a
that exposes Flow from a Room DAO. The problem I’m having is that observing this from my
Composable apparently leaks the DAO (and hence the Database instance) when the user leaves, and when the user unlocks the app again, the
is still collection this Flow, which makes the app crash. Using
fixes the issue. Am I doing something wrong by observing the Room
like this or is this some weird bug?
heckfyxe01/17/2022, 11:40 PM
Afzal Najam01/17/2022, 11:56 PM
heckfyxe01/18/2022, 12:16 AM
Afzal Najam01/18/2022, 1:20 AM
How about add to repository some checking is db authenticated or not? For example you can set db to null, when you close it, and return empty flow in repository if db is nullThanks, that’s a good idea! I’ll try to see if that works.
Alternatively you can not close db at all. Use boolean flag in Singleton and check it every onStart, set on onStop and in db creation by passphaseFeel like not closing the DB might make it a bit unsecure (insecure?), not sure but I’ll definitely try the first suggestion!