<@U5FMYU1QS> It's because use close the database a...
# anko
l
@maplonki It's because use close the database afterwards. Are you using it in a ContentProvider ?
m
yes, that call its inside my ContentProvider class
l
@maplonki Do not use
.use { … }
inside a ContentProvider because it closes the database afterwards, making it unusable from the returned
Cursor
. Just get a readable or writable reference to your db, and let Android close it when your app is killed by the system (like done for all ContentProviders)
👍 2
m
cool thanks, just to fully understand, that would be because the ContentProvider its always running right?
l
The
ContentProvider
is always available (the system wakes (starts) your app up if it's exported and another app requests access to it), but is not consuming CPU cycles when not used. However, the database remains open while your app is loaded into RAM, yes
👏 1
m
awesome, that does make sense, thanks for the explanation