Pick the fix
Strict mode reports disk reads on the main thread from prefs.getBoolean at startup. What's the best fix?
Hint 1 of 1
Which API is asynchronous?
Choose an answer, then open Show answer below to check it.
Show answer
Answer: A Move the flag to DataStore and read it as a Flow
Correct. Reads happen off the main thread and the UI reacts when the value arrives.
Why not the others?
- B Call
apply()instead ofcommit(). That affects writes, not reads. - C Read it with runBlocking on IO. Still blocks the main thread waiting.
- D Disable StrictMode. Hides the jank instead of fixing it.