I am trying to read image from asset folder. Andro...
# android
a
I am trying to read image from asset folder. Android studio gives me a warning saying: "Warning:() Inappropriate blocking method call" even though I call
open
from IO Dispatcher. My code:
Copy code
withContext(<http://Dispatchers.IO|Dispatchers.IO>) {
    context.assets.open(FILE_NAME).run {
        this.readBytes().also { file = it }
        this.close()
    }
}
Any ideas, folks?
a
Disable that inspection, it reports false positives like this all the time and isn't worth the trouble
a
Gotcha
r
small tip: you can use use() and remove the last
close()
function 🙂
👍 2
a
@Rodrigo Sicarelli Nice Closeable::use-> "Executes the given block function on this resource and then closes it down correctly whether an exception is thrown or not."
👌 1