Android - WITHOUT ROWID is only supported in SQLite version 3.8.2 or later

By xngo on January 12, 2020

As part of the improvement for my Android application, for the SQLite database, I was using the WITHOUT ROWID keywords to save around 500 KB of disk space. However, when I bundled it in my Android application, it threw the following errors messages:

.../net.openwritings.xmtl E/SQLiteLog: (1) near "WITHOUT": syntax error
.../net.openwritings.xmtl E/SQLiteLog: (11) database corruption at line 93687 of [00bb9c9ce4]
.../net.openwritings.xmtl E/SQLiteLog: (1) near "WITHOUT": syntax error
.../net.openwritings.xmtl E/SQLiteLog: (11) database corruption at line 93687 of [00bb9c9ce4]
.../net.openwritings.xmtl E/SQLiteLog: (11) malformed database schema (aminutes) - near "WITHOUT": syntax error

I found out that the WITHOUT ROWID keywords is only supported in SQLite version 3.8.2(2013-12-06) or later. My Android application is compiled with minSdkVersion 16, which uses SQLite version 3.7. I have 2 options: either force my application to use Android API 24 or forget about the WITHOUT ROWID keywords. I choose the later. Saving 500 KB out of 28 MB is negligible.

Here is the mapping of Android API versions with SQLite versions. The complete list can be found at https://developer.android.com/reference/android/database/sqlite/package-summary.html.

Android API SQLite Version
API 27 3.19
API 26 3.18
API 24 3.9
API 21 3.8
API 11 3.7
API 8 3.6
API 3 3.5
API 1 3.4

About the author

Xuan Ngo is the founder of OpenWritings.net. He currently lives in Montreal, Canada. He loves to write about programming and open source subjects.