android开发也知道,用原生的数据库开发代码量多,特别麻烦。不过,目前google已经有自己的数据库框架Room了,现在写下自己使用Room框架的一些心得体会。
官方介绍:
The Room persistence library provides an abstraction layer over SQLite to allow fluent database access while harnessing the full power of SQLite
Room持久型类库在SQLite的基础上提供了一个抽象层,方便大家流利的访问数据库,并且包含了SQLite的所有功能。很强大呀。。。
一、导入项目步骤:
1、添加仓库:我们需要在项目的build.gradle中添加google()仓库
allprojects {
repositories {
jcenter()
//添加google
google()
}
}
2、在主app的module中添加依赖
def room_version = "1.1.1"
support.room = "android.arch.persistence.room:runtime:$room_version"
support.room_compiler = "android.arch.persistence.room:compiler:$room_version