為什么使用DBFlow
DBFlow朴沿,綜合了 ActiveAndroid, Schematic, Ollie,Sprinkles 等庫的優(yōu)點雌芽。同時不是基于反射授艰,所以性能也是非常高,效率緊跟greenDAO其后世落』刺冢基于注解,使用apt技術(shù)屉佳,在編譯過程中生成操作類谷朝,使用方式和ActiveAndroid高度相似,使用簡單武花。
特性:
- 無縫支持多個數(shù)據(jù)庫圆凰;
- 使用annotation processing提高速度;
- ModelContainer類庫可以直接解析像JSON這樣的數(shù)據(jù)体箕;
- 增加靈活性的豐富接口专钉。
引入到你的工程
- 我們需要先倒入 apt plugin 庫到你的classpath,以啟用AnnotationProcessing(注解處理器):
buildscript {
repositories {
// required for this library, don't use mavenCentral()
jcenter() }
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'} }
- 然后添加我們的托管倉庫網(wǎng)址
allProjects {
repositories {
maven { url "https://jitpack.io" } } }
- 最后即可添加我們的庫到你項目級別的build.gradle文件中
apply plugin: 'com.neenbedankt.android-apt'
def dbflow_version = "3.0.0-beta2"
// or dbflow_version = "develop-SNAPSHOT" for grabbing latest dependency in your project on the develop branch
dependencies {
apt 'com.github.Raizlabs.DBFlow:dbflow-processor:${dbflow_version}'
compile "com.github.Raizlabs.DBFlow:dbflow-core:${dbflow_version}"
compile "com.github.Raizlabs.DBFlow:dbflow:${dbflow_version}"
// sql-cipher database encyrption (optional)
compile "com.github.Raizlabs.DBFlow:dbflow-sqlcipher:${dbflow_version}"
}