File tree Expand file tree Collapse file tree 6 files changed +29
-17
lines changed
src/test/java/com/github/reline/sqlite/db Expand file tree Collapse file tree 6 files changed +29
-17
lines changed Original file line number Diff line number Diff line change 11# SQLiteCopyOpenHelper
22An open helper for Android that will copy & ; open a pre-populated database
33
4+ ## Room
5+
6+ If you are using Room, utilize the built in methods for prepopulating a database.
7+ https://developer.android.com/training/data-storage/room/prepopulate
8+
49License
510--------
611
Original file line number Diff line number Diff line change 11// Top-level build file where you can add configuration options common to all sub-projects/modules.
22buildscript {
3- ext. kotlin_version = " 1.4.0"
3+ ext. kotlin_version = " 1.4.10"
4+ ext. sqlite_version = " 2.1.0"
45 repositories {
56 google()
67 jcenter()
78 }
89 dependencies {
9- classpath " com.android.tools.build:gradle:4.0 .1"
10+ classpath " com.android.tools.build:gradle:4.1 .1"
1011 classpath " org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version "
1112
1213 // NOTE: Do not place your application dependencies here; they belong
Original file line number Diff line number Diff line change @@ -29,8 +29,8 @@ dependencies {
2929 implementation fileTree(dir : " libs" , include : [" *.jar" ])
3030 implementation project(' :library' )
3131 implementation " net.zetetic:android-database-sqlcipher:4.4.0"
32- implementation " androidx.sqlite:sqlite-framework:2.1.0 "
33- implementation " androidx.sqlite:sqlite-ktx:2.1.0 "
32+ implementation " androidx.sqlite:sqlite-framework:$s qlite_version "
33+ implementation " androidx.sqlite:sqlite-ktx:$s qlite_version "
3434 implementation " org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version "
3535 implementation ' androidx.core:core-ktx:1.3.1'
3636 implementation ' androidx.appcompat:appcompat:1.2.0'
Original file line number Diff line number Diff line change 1- # Wed Aug 19 17:11:46 MST 2020
1+ # Wed Nov 11 13:53:36 MST 2020
22distributionBase =GRADLE_USER_HOME
33distributionPath =wrapper/dists
44zipStoreBase =GRADLE_USER_HOME
55zipStorePath =wrapper/dists
6- distributionUrl =https\://services.gradle.org/distributions/gradle-6.1.1-all .zip
6+ distributionUrl =https\://services.gradle.org/distributions/gradle-6.5-bin .zip
Original file line number Diff line number Diff line change 11apply plugin : ' com.android.library'
22apply plugin : ' kotlin-android'
3- apply plugin : ' kotlin-android-extensions'
43
54android {
6- compileSdkVersion 29
7- buildToolsVersion " 29 .0.3 "
5+ compileSdkVersion 30
6+ buildToolsVersion " 30 .0.2 "
87
98 defaultConfig {
109 minSdkVersion 16
11- targetSdkVersion 29
10+ targetSdkVersion 30
1211 versionCode 1
13- versionName " 1.0"
12+ versionName " 0. 1.0"
1413
1514 testInstrumentationRunner " androidx.test.runner.AndroidJUnitRunner"
1615 consumerProguardFiles " consumer-rules.pro"
@@ -32,12 +31,12 @@ android {
3231
3332dependencies {
3433 implementation " org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version "
35- implementation " androidx.sqlite:sqlite-framework:2.1.0"
36- implementation " androidx.sqlite:sqlite-ktx:2.1.0"
3734 implementation " com.squareup.okio:okio:2.6.0"
35+ implementation " androidx.sqlite:sqlite-ktx:$sqlite_version "
3836
3937 testImplementation " androidx.test.ext:junit-ktx:1.1.2"
4038 testImplementation " androidx.test:core-ktx:1.3.0"
4139 testImplementation ' org.robolectric:robolectric:4.3'
40+ testImplementation " androidx.sqlite:sqlite-framework:$sqlite_version "
4241 testImplementation ' junit:junit:4.12'
43- }
42+ }
Original file line number Diff line number Diff line change @@ -7,15 +7,23 @@ import androidx.sqlite.db.framework.FrameworkSQLiteOpenHelperFactory
77import androidx.test.core.app.ApplicationProvider
88import androidx.test.ext.junit.runners.AndroidJUnit4
99import org.junit.Assert.assertEquals
10+ import org.junit.Before
1011import org.junit.Test
1112
1213import org.junit.runner.RunWith
1314
1415@RunWith(AndroidJUnit4 ::class )
1516class SQLiteCopyOpenHelperTest {
17+
18+ private lateinit var context: Context
19+
20+ @Before
21+ fun setup () {
22+ context = ApplicationProvider .getApplicationContext()
23+ }
24+
1625 @Test
1726 fun copyEmptyDatabaseFileFromAssetPath () {
18- val context = ApplicationProvider .getApplicationContext<Context >()
1927 val config = SupportSQLiteOpenHelper .Configuration .builder(context)
2028 .callback(TestCallback ())
2129 .name(" empty.db" )
@@ -28,7 +36,6 @@ class SQLiteCopyOpenHelperTest {
2836
2937 @Test
3038 fun destructivelyMigrate () {
31- val context = ApplicationProvider .getApplicationContext<Context >()
3239 val configBuilder = SupportSQLiteOpenHelper .Configuration .builder(context)
3340 .name(" 1.db" )
3441
@@ -66,4 +73,4 @@ private class TestCallback(version: Int = 1) : SupportSQLiteOpenHelper.Callback(
6673 override fun onUpgrade (db : SupportSQLiteDatabase , oldVersion : Int , newVersion : Int ) {
6774 // TODO("Not yet implemented")
6875 }
69- }
76+ }
You can’t perform that action at this time.
0 commit comments