-
Notifications
You must be signed in to change notification settings - Fork 128
Using a custom SQLite build
SquiDB allows you to connect to a custom SQLite build instead of the stock build that ships with Android. This can be helpful if you want to be sure you are using the latest and greatest SQLite version or need some feature/behavior that was not present in the older versions of SQLite that ship with older versions of Android.
A new module, squidb-sqlite-bindings
, has been added to the SquiDB project. This module is based on the excellent Android SQLite Bindings project from the SQLite developers and contains a copy of the code from that project, along with the SQLite amalgamation source files for the latest version of SQLite. If you want your databases to use the latest version of SQLite, you can add this module as a dependency in your build.gradle:
dependencies {
compile 'com.yahoo.squidb:squidb-sqlite-bindings:3.0.0'
...
}
Or, if you want to swap in your own version of the SQLite amalgamation files, you can clone the module and build it from source. You'll have to invoke ndk-build once to generate the native libraries, but fortunately the SQLite developers have made this very easy. See the Android SQLite Bindings project for instructions.
Once you've added the squidb-sqlite-bindings module as a dependency, using it in your app only requires a few lines of code. In your SquidDatabase subclass, add the following lines of code:
@Override
protected ISQLiteOpenHelper createOpenHelper(String databaseName,
OpenHelperDelegate delegate, int version) {
return new SQLiteBindingsOpenHelper(context, databaseName, delegate, version);
}
That's it! That database will now use your custom SQLite build instead of the stock Android build.
Note that the squidb-sqlite-bindings
project may not work with all builds of SQLite. It is only guaranteed to work with builds supported by the SQLite developers, since it relies on their bindings project for much of the heavy lifting. It may not work with highly customized builds. If you want to experiment with other SQLite builds, you can clone the squidb-sqlite-bindings
project and try to substitute a custom build of SQLite.