1、导入依赖库:
implementation 'androidx.room:room-runtime:2.2.5'
implementation 'androidx.room:room-ktx:2.2.5'
kapt 'androidx.room:room-compiler:2.2.5'
implementation "androidx.paging:paging-runtime:2.1.2"
如果有冲突,可以加上:
configurations {
all*.exclude group: 'com.google.guava', module: 'listenablefuture'
}
数据库文件存在手机的路径为:data/data/包名/databases/**.db
2、运行界面
点击修改后的效果图:
如果插入出现报错:Channel is unrecoverably broken and will be disposed!
解决办法:应用卸载重新安装
最后,代码下载地址为: