If you’re developing an Android application, you’ve likely enabled StrictMode. e.g.

if (BuildConfig.DEBUG) {
    StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
            .detectAll()
            .penaltyLog()
            .penaltyDeath()
            .build());
    StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
            .detectAll()
            .penaltyLog()
            .penaltyDeath()
            .build());
}

which, among other things, will cause your build to log & crash when you do a disk read on the main thread.

If you’re convinced that you have an exceptional need to perform disk access on the main thread (or you just don’t think it’s worth dealing with AsyncTask and it’s callbacks), you can temporarily disable the check with the following pattern:

StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
try {
    // your code that absolutely needs to do a disk read
} finally {
    StrictMode.setThreadPolicy(oldPolicy);
}

Note that this won’t prevent your UI from becoming unresponsive or raising an ANR, so be careful.