SQLite Across Every Port: One Contract, One Encrypted File Format
The original com.codename1.db implementation delegated SQLite calls to the database supplied by each operating system. We knew this was less portable than the rest of Codename One, but fixing it meant taking ownership of SQLite on every target. That looked like a deep rabbit hole, so we exposed escape hatches instead. The pluggable SpatiaLite work we described in 2018 is one example. What is…
Codename One is an open-source framework that allows developers to build native apps for iOS, Android, desktop, and web platforms using a single Java or Kotlin codebase. However, the original implementation of SQLite could vary greatly between operating systems, leading to inconsistencies in functionality and behavior.
To address these issues, a new contract for SQLite was established, ensuring a consistent and reliable experience across all platforms. This included native implementations on Windows and Linux, SQLite compiled to WebAssembly for JavaScript environments, and encryption support using the SQLCipher 4 library.
The pluggable SpatiaLite work from 2018 was expanded upon to provide a single tested SQLite contract, resolving long-standing problems such as encrypted databases opening inconsistently on different ports and platforms. The new DatabaseConformanceSuite defines the contract and includes tests for lifecycle, statements, cursors, transactions, encryption, and legacy behavior on every supported platform.
With these improvements, developers can now expect a uniform SQLite experience regardless of the target platform. The new DatabaseConfig allows for encryption to be enabled or disabled based on the desired key model, which can be a user-passphrase, a managed key stored in Android Keystore or iOS keychain, or a raw key supplied by the application. Existing plaintext databases can also be encrypted without changing the API.
These changes bring Codename One's database functionality up to par with other native frameworks, providing a more consistent and reliable experience for developers and their users.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.