Simple yet powerful SQLite database layer for Android that makes database handling feel like magic.
The Intellij plugin can be installed from Android Studio by navigating Android Studio -> Preferences -> Plugins -> Browse repositories -> Search for SqliteMagic
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:<latest version>'
classpath 'com.siimkinks.sqlitemagic:sqlitemagic-plugin:0.25.1'
}
}
apply plugin: 'com.android.application'
apply plugin: 'com.siimkinks.sqlitemagic'
SqliteMagic.builder(applicationContext)
.sqliteFactory(new FrameworkSQLiteOpenHelperFactory())
.openDefaultConnection();
Note: any place with a reference to Application context is ok to use for initialization, but it must happen before a database is accessed. During initialization default db connection is opened, db schema is created and migration scripts are executed - no other hidden runtime performance costs.
Note that there is no need to extend or implement any base classes or interfaces
POJO | AutoValue |
---|---|
|
|
Kotlin | |
|
Database operation builder methods for Java are "automagically" generated during compile time on objects with @Table
annotation using bytecode manipulation and AST transformations. These methods may seem like "magic", but actually they are only glue methods that call corresponding table generated class methods. This way one can still see human readable code during debugging - just press "step into" when magic method is encountered.
For kotlin, database operation builder methods are generated as extensions functions.
Synchronous | RxJava |
---|---|
|
|
(All database operations trigger RxJava notifications on active queries that listen to table that is being modified)
Synchronous | RxJava |
---|---|
|
|
SqliteMagic ships with its own DSL (or Domain Specific Language) that emulates SQL in Java (inspired by JOOQ).
Synchronous | RxJava |
---|---|
|
|
Synchronous | RxJava |
---|---|
|
|
There is so much more to querying data like SQL functions, views, more type safety, selecting columns, querying only the first result, counting, RxJava convenience operators, etc. Take a deeper look at the wiki.
All updates can be found in the CHANGELOG.
For bugs, questions and discussions please use the Github Issues.
Copyright 2020 Siim Kinks
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.