【发布时间】:2020-03-01 08:17:35
【问题描述】:
我在https://blog.mindorks.com/powerful-android-orm-greendao-3-tutorial 的指导下将greenDAO 集成到我的android 项目中,我遵循一切(或者我认为XD),当我在我的手机上尝试时,它没有创建表,而是创建了数据库文件,但是当我用查看器打开它没有显示任何内容。
我不知道如何在模拟器中进行测试,看看是手机问题还是我需要的某些权限问题。
我会离开这个项目,看看你能不能帮帮我,非常感谢。
https://anonfile.com/R6j6J2d5o1/Test_zip
文件清单
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.cafl.test">
<application
android:name="com.cafl.test.AppDbController"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name="com.cafl.test.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
文件 gradle 项目
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.0'
classpath 'org.greenrobot:greendao-gradle-plugin:3.2.2'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
文件 gradle 模块
apply plugin: 'com.android.application'
apply plugin: 'org.greenrobot.greendao'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.cafl.test"
minSdkVersion 23
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
greendao{
schemaVersion 1
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'org.greenrobot:greendao:3.2.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
其创建的 DaoMaster 和 DaoSession 用于构建项目
并且在我测试时,我使用的是原始的 DaoMaster 功能
mDaoSession = new DaoMaster(
new DaoMaster.DevOpenHelper(this, "greendao_demo.db").getWritableDb()).newSession();
【问题讨论】:
标签: android database sqlite android-studio greendao