A Magisk, KernelSU (KSU), and APatch compatible module containing standalone SQLite3 binaries for Android.
Some Android editions don't include an SQLite3 command accessible on the command line. This module is for those needing to work with SQLite databases on the command line but who are unable to use alternatives like the sqlite3 Termux package.
The module detects the correct architecture and NDK at install. It uses the root overlay to place the sqlite3 binary in an executable directory very commonly in $PATH without modifying any real partitions.
For Android 7.1 and up, this is /product/bin, and for older devices it is /system/bin.
This means the sqlite3 command should be accessible regardless of which terminal emulator (or ADB, or Java call) you use.
This repository contains release builds as ready-to-go universal Magisk/KSU/APatch modules for each Android SDK compatibility window.
Each module contains all the architectures (ABIs) supported by the matching NDK and will copy the correct one at install time (customize.sh script).
For devices up to Android 4.4.4 KitKat, install the module labelled Android-1.5-To-7.0 (built with NDK 14).
For all devices from Android 5.0 Lollipop onwards, install the module labelled Android-5.0-To-... (built with NDK 29).
In order to build sqlite3 for Android yourself, you need a copy of the correct NDK for the target Android SDK.
You can use the Get-NDK.ps1 script to download and extract an NDK for your system architecture.
Running the script with no parameters will download the latest stable NDK for the current operating system and extract it to ./ndk in the repo.
./Get-NDK.ps1 [[-Version] <int[]>] [[-NdkDir] <String>] [[-TempDir] <String>] [[-ForcePlatform] <String>] [-KeepArchive] [-AllPlatforms] [-NoExtract] [-NoVerify] [<CommonParameters>]-Version <ver>specifies the NDK version to download. Defaults to the latest release (excluding betas).-NdkDir <path>specifies where to extract the NDK files. Defaults to ./NDK relative to the script.-TempDir <path>specifies the staging directory for downloading/extracting the NDK files. Defaults to the user's temp path.-KeepArchiveretains the downloaded NDK archive files in the temp path.-ForcePlatformdownloads the NDK for a specific platform.-AllPlatformsdownloads all supported editions of the NDK (currently 64-bit Windows, Linux, or macOS). This overrides-ForcePlatform.-NoExtractdownloads the NDK archive but doesn't attempt to extract it.-NoVerifyskips checking archives against stored file hashes before extracting.
The repository already contains SQLite3 amalgamated source in the ./src directory.
You can optionally download the latest (or a specific) version with Get-SQLiteSource.ps1
./Get-SQLiteSource.ps1 [-Latest] [-SourceDir <string>] [<CommonParameters>]
./Get-SQLiteSource.ps1 -Version <version> [-SourceDir <string>] [<CommonParameters>]-Latestgets the latest SQLite version published in the changelog.-Version <ver>gets a specific SQLite version as listed in the changelog.-SourceDir <path>specifies where to save the source code. Defaults to ./src relative to the script.
The build script can build many combinations of target SDKs and NDKs. If you are running an older device or one with an architecture that's no longer supported, such as ARMv5, you will need to use an earlier NDK.
Please see the NDK compatibility page for more details.
MIPS and ARMv5 (armeabi) were supported up to and including NDK 16 (but SQLite's modules will not compile on MIPS anyway).
ARM64-v8a, ARMv7-A, x86_64, x86, and riscv64 are currently supported by the latest NDK.
./Build-SQLite.ps1 [[-NdkDir] <string>] [[-SourceDir] <string>] [[-BuildDir] <string>] [[-OutDir] <string>] [[-TargetArch] <string[]>] [[-TargetSdk] <int[]>] [[-ForceNdk] <int>] [[-Options] <string>] [-Clean] [<CommonParameters>]-NdkDir <path>specifies the location of the NDK to use for building. Defaults to ./ndk relative to the script.-SourceDir <path>specifies the location the source code to build. Defaults to ./src relative to the script.-BuildDir <path>specifies where to run the build operations. Defaults to ./build relative to the script.-OutDir <path>specifies where to copy the compiled binaries on successful build. Defaults to ./out relative to the script.-TargetArch <string[]>specifies all the architectures to build for each SDK target. Unsupported arches are skipped. Defaults to all.-TargetSdk <int[]>specifies all the SDK targets to build for. You should ideally set this to the target device's current SDK level (see below). Defaults to the latest RTM Android version.-ForceNdk <int>forces the installer to use the specified NDK release instead of automatically selecting the latest supported by the target SDK.-Options <string>allows enabling SQLite optional features and other compile options. Separate with spaces.-Cleancleans up build files and artifacts from any previous builds. Archives fromBuild-ModulePackage.ps1are preserved.
This script takes the output from a build and creates a module archive that can be installed with Magisk, KSU, or APatch manager.
./Build-ModulePackage.ps1 [-SourceDir] <string> [[-OutDir] <string>] [-KeepStageDir] [<CommonParameters>]-SourceDir <path>specifies the location of the build artifacts produced byBuild-SQLite.ps1. This always ends in the format SKDx_NDKy.-OutDir <path>specifies where to save the complete module archive. Defaults to ./out relative to the script.-KeepStageDirprevents the script from deleting the staging directory where module files are copied before compression. Always a GUID/UUID.
With the -Options parameter, you can specify any compile-time options.
You don't need to include the -D prefix.
For example:
./Build-SQLite.ps1 ... -Options 'SQLITE_ENABLE_FTS5 SQLITE_ENABLE_RTREE SQLITE_DQS=0 SQLITE_THREADSAFE=0'This enables the Full Text Search v5 engine, the R*Tree extension, disables double-quoted string literals, and turns off thread-safety. For developers, this is equivalent to the following CFLAGS:
-DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_RTREE -DSQLITE_DQS=0 -DSQLITE_THREADSAFE=0
The build scripts in this repo are licensed under the permissive MIT License.
The SQLite source is in the public domain.
- SQLite — source
- EXALAB/sqlite3-android — inspired many configuration choices