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 1
1
# SQLiteCopyOpenHelper
2
2
An open helper for Android that will copy & ; open a pre-populated database
3
3
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
+
4
9
License
5
10
--------
6
11
Original file line number Diff line number Diff line change 1
1
// Top-level build file where you can add configuration options common to all sub-projects/modules.
2
2
buildscript {
3
- ext. kotlin_version = " 1.4.0"
3
+ ext. kotlin_version = " 1.4.10"
4
+ ext. sqlite_version = " 2.1.0"
4
5
repositories {
5
6
google()
6
7
jcenter()
7
8
}
8
9
dependencies {
9
- classpath " com.android.tools.build:gradle:4.0 .1"
10
+ classpath " com.android.tools.build:gradle:4.1 .1"
10
11
classpath " org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version "
11
12
12
13
// 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 {
29
29
implementation fileTree(dir : " libs" , include : [" *.jar" ])
30
30
implementation project(' :library' )
31
31
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 "
34
34
implementation " org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version "
35
35
implementation ' androidx.core:core-ktx:1.3.1'
36
36
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
2
2
distributionBase =GRADLE_USER_HOME
3
3
distributionPath =wrapper/dists
4
4
zipStoreBase =GRADLE_USER_HOME
5
5
zipStorePath =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 1
1
apply plugin : ' com.android.library'
2
2
apply plugin : ' kotlin-android'
3
- apply plugin : ' kotlin-android-extensions'
4
3
5
4
android {
6
- compileSdkVersion 29
7
- buildToolsVersion " 29 .0.3 "
5
+ compileSdkVersion 30
6
+ buildToolsVersion " 30 .0.2 "
8
7
9
8
defaultConfig {
10
9
minSdkVersion 16
11
- targetSdkVersion 29
10
+ targetSdkVersion 30
12
11
versionCode 1
13
- versionName " 1.0"
12
+ versionName " 0. 1.0"
14
13
15
14
testInstrumentationRunner " androidx.test.runner.AndroidJUnitRunner"
16
15
consumerProguardFiles " consumer-rules.pro"
@@ -32,12 +31,12 @@ android {
32
31
33
32
dependencies {
34
33
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"
37
34
implementation " com.squareup.okio:okio:2.6.0"
35
+ implementation " androidx.sqlite:sqlite-ktx:$sqlite_version "
38
36
39
37
testImplementation " androidx.test.ext:junit-ktx:1.1.2"
40
38
testImplementation " androidx.test:core-ktx:1.3.0"
41
39
testImplementation ' org.robolectric:robolectric:4.3'
40
+ testImplementation " androidx.sqlite:sqlite-framework:$sqlite_version "
42
41
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
7
7
import androidx.test.core.app.ApplicationProvider
8
8
import androidx.test.ext.junit.runners.AndroidJUnit4
9
9
import org.junit.Assert.assertEquals
10
+ import org.junit.Before
10
11
import org.junit.Test
11
12
12
13
import org.junit.runner.RunWith
13
14
14
15
@RunWith(AndroidJUnit4 ::class )
15
16
class SQLiteCopyOpenHelperTest {
17
+
18
+ private lateinit var context: Context
19
+
20
+ @Before
21
+ fun setup () {
22
+ context = ApplicationProvider .getApplicationContext()
23
+ }
24
+
16
25
@Test
17
26
fun copyEmptyDatabaseFileFromAssetPath () {
18
- val context = ApplicationProvider .getApplicationContext<Context >()
19
27
val config = SupportSQLiteOpenHelper .Configuration .builder(context)
20
28
.callback(TestCallback ())
21
29
.name(" empty.db" )
@@ -28,7 +36,6 @@ class SQLiteCopyOpenHelperTest {
28
36
29
37
@Test
30
38
fun destructivelyMigrate () {
31
- val context = ApplicationProvider .getApplicationContext<Context >()
32
39
val configBuilder = SupportSQLiteOpenHelper .Configuration .builder(context)
33
40
.name(" 1.db" )
34
41
@@ -66,4 +73,4 @@ private class TestCallback(version: Int = 1) : SupportSQLiteOpenHelper.Callback(
66
73
override fun onUpgrade (db : SupportSQLiteDatabase , oldVersion : Int , newVersion : Int ) {
67
74
// TODO("Not yet implemented")
68
75
}
69
- }
76
+ }
You can’t perform that action at this time.
0 commit comments