3

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?

Ognyan
  • 13,452
  • 5
  • 64
  • 82

1 Answers1

3

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

CL.
  • 173,858
  • 17
  • 217
  • 259
  • I see. But then what is the explanation that in the past it was triggering the StrictMode (like in this question for example http://stackoverflow.com/questions/11963601/android-strictmode-policy)? – Ognyan Jun 29 '16 at 12:25
  • As shown in the stack trace, that implementation of `SQLiteDatabase` had added explicit strict mode checks. This was probably removed because not all SQL statements necessarily access the disk. – CL. Jun 29 '16 at 13:56