requery / sqlite-android
- среда, 6 апреля 2016 г. в 03:13:37
Java
Android SQLite support library
This is an Android specific distribution of the latest versions of SQLite. It contains the latest SQLite version and the Android specific database APIs derived from AOSP packaged as an AAR library distributed on jcenter.
Even the latest version of Android is several versions behind the latest version of SQLite. Theses versions do not have the bug fixes, performance improvements, or new features present in current versions of SQLite. This problem is worse the older the version of the OS the device has. Using this library you can keep up to date with the latest versions of SQLite and provide a consistent version across OS versions and devices.
Use new SQLite features:
This library contains an optimized version of the Android database wrapper API native code that along with newer optimized sqlite versions provide better performance than the current Android database API in generally all cases.
On mid range devices running Android KitKat this library can be up to 40% faster on read operations. Performance varies greatly between different devices and OS versions. On newer OS versions & devices the performance improvement is generally smaller as those versions contain newer SQLite versions.
dependencies {
compile 'io.requery:sqlite-android:3.12.0'
}
Then change usages of android.database.sqlite.SQLiteDatabase
to
io.requery.android.database.sqlite.SQLiteDatabase
, similarly extend
io.requery.android.database.sqlite.SQLiteOpenHelper
instead of
android.database.sqlite.SQLiteOpenHelper
. Note similar changes maybe required for classes that
depended on android.database.sqlite.SQLiteDatabase
equivalent APIs are provided in the
io.requery.android.database.sqlite
package.
If you expose Cursor
instances across processes you should wrap the returned cursors in a
CrossProcessCursorWrapper
for performance reasons the cursors are not cross process by default.
The native library is built for the following CPU architectures:
armeabi-v7a
arm64-v8a
x86
However you may not want to include all binaries in your apk. You can exclude certain variants by
using packagingOptions
:
android {
packagingOptions {
exclude 'lib/arm64-v8a/libsqlite3x.so'
exclude 'lib/x86/libsqlite3x.so'
}
}
The size of the artifacts with only the armeabi-v7a binary is ~500kb. In general you can use armeabi-v7a on the majority of Android devices including Intel Atom which provides a native translation layer, however performance under the translation layer is worse than using the x86 binary.
The library is versioned after the version of SQLite it contains. For changes specific to just the wrapper API a revision number is added e.g. 3.12.0-X, where X is the revision number.
This project is based on the AOSP code and the Android SQLite bindings No official distributions are made from the Android SQLite bindings it and it has not been updated in a while, this project starts there and makes significant changes:
CancellationSignal
SQLiteOpenHelper.getDatabaseLocked()
wrong path to openOrCreateDatabase
Copyright (C) 2016 requery.io
Copyright (C) 2005-2012 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.