androidsqliteandroid-strictmode

Why StrictMode does not catch read/write operations by SQLite?


In my app I have the following setup for StrictMode:

    StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
            .detectDiskReads()
            .detectDiskWrites()
            .detectNetwork()
            .penaltyLog()
            .penaltyDeath()
            .build());

At some point I've noticed that I have few places where SQLite operations are not placed in separate thread but nevertheless they don't trigger StrictMode violation. I've tested on real device with Android 5.1.1 and on Genymotions with 4.4.4 and 5.1.1 with the same result. I have recollections that SQLite operations used to trigger StrictMode violations but now that is not the case. Any idea why?

I saw in the documentation the following:

Notably, disk or network access from JNI calls won't necessarily trigger it.

Is that the reason?


Solution

  • SQLite is a library written in C, so all accesses to the database file are indeed hidden inside JNI calls.