為什么使用DBFlow
DBFlow,綜合了 ActiveAndroid, Schematic, Ollie,Sprinkles 等庫(kù)的優(yōu)點(diǎn)。同時(shí)不是基于反射,所以性能也是非常高,效率緊跟greenDAO其后?;谧⒔?,使用apt技術(shù),在編譯過(guò)程中生成操作類,使用方式和ActiveAndroid高度相似,使用簡(jiǎn)單。
特性:
- 無(wú)縫支持多個(gè)數(shù)據(jù)庫(kù);
- 使用annotation processing提高速度;
- ModelContainer類庫(kù)可以直接解析像JSON這樣的數(shù)據(jù);
- 增加靈活性的豐富接口。
引入到你的工程
- 我們需要先倒入 apt plugin 庫(kù)到你的classpath,以啟用AnnotationProcessing(注解處理器):
buildscript {
repositories {
// required for this library, don't use mavenCentral()
jcenter() }
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'} }
- 然后添加我們的托管倉(cāng)庫(kù)網(wǎng)址
allProjects {
repositories {
maven { url "https://jitpack.io" } } }
- 最后即可添加我們的庫(kù)到你項(xiàng)目級(jí)別的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}"
}