├── .gitattributes ├── .gitignore ├── .gradle ├── 4.1 │ ├── fileChanges │ │ └── last-build.bin │ ├── fileContent │ │ └── fileContent.lock │ ├── fileHashes │ │ ├── fileHashes.bin │ │ ├── fileHashes.lock │ │ └── resourceHashesCache.bin │ ├── javaCompile │ │ ├── classAnalysis.bin │ │ ├── jarAnalysis.bin │ │ ├── javaCompile.lock │ │ ├── taskHistory.bin │ │ └── taskJars.bin │ └── taskHistory │ │ ├── fileSnapshots.bin │ │ ├── taskHistory.bin │ │ └── taskHistory.lock └── buildOutputCleanup │ ├── built.bin │ ├── cache.properties │ └── cache.properties.lock ├── .idea ├── gradle.xml ├── libraries │ ├── android_arch_core_common_1_0_0_jar.xml │ ├── android_arch_lifecycle_common_1_0_0_jar.xml │ ├── android_arch_lifecycle_runtime_1_0_0.xml │ ├── com_android_support_animated_vector_drawable_26_1_0.xml │ ├── com_android_support_appcompat_v7_26_1_0.xml │ ├── com_android_support_constraint_constraint_layout_1_0_2.xml │ ├── com_android_support_constraint_constraint_layout_solver_1_0_2_jar.xml │ ├── com_android_support_support_annotations_26_1_0_jar.xml │ ├── com_android_support_support_compat_26_1_0.xml │ ├── com_android_support_support_core_ui_26_1_0.xml │ ├── com_android_support_support_core_utils_26_1_0.xml │ ├── com_android_support_support_fragment_26_1_0.xml │ ├── com_android_support_support_media_compat_26_1_0.xml │ ├── com_android_support_support_v4_26_1_0.xml │ ├── com_android_support_support_vector_drawable_26_1_0.xml │ ├── com_android_support_test_espresso_espresso_core_3_0_1.xml │ ├── com_android_support_test_espresso_espresso_idling_resource_3_0_1.xml │ ├── com_android_support_test_rules_1_0_1.xml │ ├── com_android_support_test_runner_1_0_1.xml │ ├── com_google_code_findbugs_jsr305_2_0_1_jar.xml │ ├── com_squareup_javawriter_2_1_1_jar.xml │ ├── javax_inject_javax_inject_1_jar.xml │ ├── junit_junit_4_12_jar.xml │ ├── net_sf_kxml_kxml2_2_3_0_jar.xml │ ├── org_hamcrest_hamcrest_core_1_3_jar.xml │ ├── org_hamcrest_hamcrest_integration_1_3_jar.xml │ ├── org_hamcrest_hamcrest_library_1_3_jar.xml │ ├── org_jetbrains_annotations_13_0_jar.xml │ ├── org_jetbrains_kotlin_kotlin_stdlib_1_1_60_jar.xml │ └── org_jetbrains_kotlin_kotlin_stdlib_jre7_1_1_60_jar.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── workspace.xml ├── SqliteExample.iml ├── app ├── .gitignore ├── app.iml ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── example │ │ └── vicky │ │ └── sqliteexample │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── example │ │ │ └── vicky │ │ │ └── sqliteexample │ │ │ ├── DataBaseHandler.kt │ │ │ ├── MainActivity.kt │ │ │ └── User.kt │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── example │ └── vicky │ └── sqliteexample │ └── ExampleUnitTest.kt ├── build.gradle ├── build ├── android-profile │ ├── profile-2017-11-28-22-14-15-422.json │ ├── profile-2017-11-28-22-14-15-422.rawproto │ ├── profile-2017-11-28-22-14-52-428.json │ ├── profile-2017-11-28-22-14-52-428.rawproto │ ├── profile-2017-11-28-22-41-46-965.json │ ├── profile-2017-11-28-22-41-46-965.rawproto │ ├── profile-2017-12-01-20-24-29-159.json │ ├── profile-2017-12-01-20-24-29-159.rawproto │ ├── profile-2017-12-01-20-24-44-305.json │ ├── profile-2017-12-01-20-24-44-305.rawproto │ ├── profile-2017-12-02-21-19-50-815.json │ ├── profile-2017-12-02-21-19-50-815.rawproto │ ├── profile-2017-12-02-21-20-19-169.json │ ├── profile-2017-12-02-21-20-19-169.rawproto │ ├── profile-2017-12-02-21-22-40-068.json │ ├── profile-2017-12-02-21-22-40-068.rawproto │ ├── profile-2017-12-02-21-46-21-825.json │ ├── profile-2017-12-02-21-46-21-825.rawproto │ ├── profile-2017-12-02-21-47-25-404.json │ ├── profile-2017-12-02-21-47-25-404.rawproto │ ├── profile-2017-12-02-22-00-16-526.json │ ├── profile-2017-12-02-22-00-16-526.rawproto │ ├── profile-2017-12-02-22-01-38-316.json │ ├── profile-2017-12-02-22-01-38-316.rawproto │ ├── profile-2017-12-02-22-02-39-235.json │ ├── profile-2017-12-02-22-02-39-235.rawproto │ ├── profile-2017-12-02-22-04-01-845.json │ ├── profile-2017-12-02-22-04-01-845.rawproto │ ├── profile-2017-12-03-18-36-52-335.json │ ├── profile-2017-12-03-18-36-52-335.rawproto │ ├── profile-2017-12-03-18-37-08-912.json │ └── profile-2017-12-03-18-37-08-912.rawproto └── kotlin-build │ └── version.txt ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── local.properties └── settings.gradle /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | Java.gitignore -------------------------------------------------------------------------------- /.gradle/4.1/fileChanges/last-build.bin: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gradle/4.1/fileContent/fileContent.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kmvignesh/SqliteExample/631ec8c78df86790441931dafcff9750f63a7d40/.gradle/4.1/fileContent/fileContent.lock -------------------------------------------------------------------------------- /.gradle/4.1/fileHashes/fileHashes.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kmvignesh/SqliteExample/631ec8c78df86790441931dafcff9750f63a7d40/.gradle/4.1/fileHashes/fileHashes.bin -------------------------------------------------------------------------------- /.gradle/4.1/fileHashes/fileHashes.lock: -------------------------------------------------------------------------------- 1 | ~]%]6zJD � -------------------------------------------------------------------------------- /.gradle/4.1/fileHashes/resourceHashesCache.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kmvignesh/SqliteExample/631ec8c78df86790441931dafcff9750f63a7d40/.gradle/4.1/fileHashes/resourceHashesCache.bin -------------------------------------------------------------------------------- /.gradle/4.1/javaCompile/classAnalysis.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kmvignesh/SqliteExample/631ec8c78df86790441931dafcff9750f63a7d40/.gradle/4.1/javaCompile/classAnalysis.bin -------------------------------------------------------------------------------- /.gradle/4.1/javaCompile/jarAnalysis.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kmvignesh/SqliteExample/631ec8c78df86790441931dafcff9750f63a7d40/.gradle/4.1/javaCompile/jarAnalysis.bin -------------------------------------------------------------------------------- /.gradle/4.1/javaCompile/javaCompile.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kmvignesh/SqliteExample/631ec8c78df86790441931dafcff9750f63a7d40/.gradle/4.1/javaCompile/javaCompile.lock -------------------------------------------------------------------------------- /.gradle/4.1/javaCompile/taskHistory.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kmvignesh/SqliteExample/631ec8c78df86790441931dafcff9750f63a7d40/.gradle/4.1/javaCompile/taskHistory.bin -------------------------------------------------------------------------------- /.gradle/4.1/javaCompile/taskJars.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kmvignesh/SqliteExample/631ec8c78df86790441931dafcff9750f63a7d40/.gradle/4.1/javaCompile/taskJars.bin -------------------------------------------------------------------------------- /.gradle/4.1/taskHistory/fileSnapshots.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kmvignesh/SqliteExample/631ec8c78df86790441931dafcff9750f63a7d40/.gradle/4.1/taskHistory/fileSnapshots.bin -------------------------------------------------------------------------------- /.gradle/4.1/taskHistory/taskHistory.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kmvignesh/SqliteExample/631ec8c78df86790441931dafcff9750f63a7d40/.gradle/4.1/taskHistory/taskHistory.bin -------------------------------------------------------------------------------- /.gradle/4.1/taskHistory/taskHistory.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kmvignesh/SqliteExample/631ec8c78df86790441931dafcff9750f63a7d40/.gradle/4.1/taskHistory/taskHistory.lock -------------------------------------------------------------------------------- /.gradle/buildOutputCleanup/built.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kmvignesh/SqliteExample/631ec8c78df86790441931dafcff9750f63a7d40/.gradle/buildOutputCleanup/built.bin -------------------------------------------------------------------------------- /.gradle/buildOutputCleanup/cache.properties: -------------------------------------------------------------------------------- 1 | #Tue Nov 28 22:14:10 IST 2017 2 | gradle.version=4.1 3 | -------------------------------------------------------------------------------- /.gradle/buildOutputCleanup/cache.properties.lock: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | -------------------------------------------------------------------------------- /.idea/libraries/android_arch_core_common_1_0_0_jar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/android_arch_lifecycle_common_1_0_0_jar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/android_arch_lifecycle_runtime_1_0_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/libraries/com_android_support_animated_vector_drawable_26_1_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/libraries/com_android_support_appcompat_v7_26_1_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/libraries/com_android_support_constraint_constraint_layout_1_0_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/libraries/com_android_support_constraint_constraint_layout_solver_1_0_2_jar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/libraries/com_android_support_support_annotations_26_1_0_jar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/com_android_support_support_compat_26_1_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/libraries/com_android_support_support_core_ui_26_1_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/libraries/com_android_support_support_core_utils_26_1_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/libraries/com_android_support_support_fragment_26_1_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/libraries/com_android_support_support_media_compat_26_1_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/libraries/com_android_support_support_v4_26_1_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/libraries/com_android_support_support_vector_drawable_26_1_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/libraries/com_android_support_test_espresso_espresso_core_3_0_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/libraries/com_android_support_test_espresso_espresso_idling_resource_3_0_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/libraries/com_android_support_test_rules_1_0_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/libraries/com_android_support_test_runner_1_0_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/libraries/com_google_code_findbugs_jsr305_2_0_1_jar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/libraries/com_squareup_javawriter_2_1_1_jar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/javax_inject_javax_inject_1_jar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/junit_junit_4_12_jar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/net_sf_kxml_kxml2_2_3_0_jar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/libraries/org_hamcrest_hamcrest_core_1_3_jar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/org_hamcrest_hamcrest_integration_1_3_jar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/org_hamcrest_hamcrest_library_1_3_jar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/org_jetbrains_annotations_13_0_jar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/libraries/org_jetbrains_kotlin_kotlin_stdlib_1_1_60_jar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/org_jetbrains_kotlin_kotlin_stdlib_jre7_1_1_60_jar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16 | 26 | 27 | 28 | 29 | 30 | 31 | 33 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /SqliteExample.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/app.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 23 | 24 | 25 | 26 | 27 | 28 | 44 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | apply plugin: 'kotlin-android' 4 | 5 | apply plugin: 'kotlin-android-extensions' 6 | 7 | android { 8 | compileSdkVersion 26 9 | defaultConfig { 10 | applicationId "com.example.vicky.sqliteexample" 11 | minSdkVersion 19 12 | targetSdkVersion 26 13 | versionCode 1 14 | versionName "1.0" 15 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 16 | } 17 | buildTypes { 18 | release { 19 | minifyEnabled false 20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 21 | } 22 | } 23 | } 24 | 25 | dependencies { 26 | implementation fileTree(dir: 'libs', include: ['*.jar']) 27 | implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" 28 | implementation 'com.android.support:appcompat-v7:26.1.0' 29 | implementation 'com.android.support.constraint:constraint-layout:1.0.2' 30 | testImplementation 'junit:junit:4.12' 31 | androidTestImplementation 'com.android.support.test:runner:1.0.1' 32 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' 33 | } 34 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/example/vicky/sqliteexample/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.example.vicky.sqliteexample 2 | 3 | import android.support.test.InstrumentationRegistry 4 | import android.support.test.runner.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getTargetContext() 22 | assertEquals("com.example.vicky.sqliteexample",appContext.packageName) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/vicky/sqliteexample/DataBaseHandler.kt: -------------------------------------------------------------------------------- 1 | package com.example.vicky.sqliteexample 2 | 3 | import android.content.ContentValues 4 | import android.content.Context 5 | import android.database.sqlite.SQLiteDatabase 6 | import android.database.sqlite.SQLiteOpenHelper 7 | import android.widget.Toast 8 | 9 | /** 10 | * Created by VickY on 2017-11-28. 11 | */ 12 | 13 | val DATABASE_NAME ="MyDB" 14 | val TABLE_NAME="Users" 15 | val COL_NAME = "name" 16 | val COL_AGE = "age" 17 | val COL_ID = "id" 18 | 19 | class DataBaseHandler(var context: Context) : SQLiteOpenHelper(context,DATABASE_NAME,null,1){ 20 | override fun onCreate(db: SQLiteDatabase?) { 21 | 22 | val createTable = "CREATE TABLE " + TABLE_NAME +" (" + 23 | COL_ID +" INTEGER PRIMARY KEY AUTOINCREMENT," + 24 | COL_NAME + " VARCHAR(256)," + 25 | COL_AGE +" INTEGER)" 26 | 27 | db?.execSQL(createTable) 28 | 29 | } 30 | 31 | override fun onUpgrade(db: SQLiteDatabase?,oldVersion: Int,newVersion: Int) { 32 | TODO("not implemented") //To change body of created functions use File | Settings | File Templates. 33 | } 34 | 35 | fun insertData(user : User){ 36 | val db = this.writableDatabase 37 | var cv = ContentValues() 38 | cv.put(COL_NAME,user.name) 39 | cv.put(COL_AGE,user.age) 40 | var result = db.insert(TABLE_NAME,null,cv) 41 | if(result == -1.toLong()) 42 | Toast.makeText(context,"Failed",Toast.LENGTH_SHORT).show() 43 | else 44 | Toast.makeText(context,"Success",Toast.LENGTH_SHORT).show() 45 | } 46 | 47 | fun readData() : MutableList{ 48 | var list : MutableList = ArrayList() 49 | 50 | val db = this.readableDatabase 51 | val query = "Select * from " + TABLE_NAME 52 | val result = db.rawQuery(query,null) 53 | if(result.moveToFirst()){ 54 | do { 55 | var user = User() 56 | user.id = result.getString(result.getColumnIndex(COL_ID)).toInt() 57 | user.name = result.getString(result.getColumnIndex(COL_NAME)) 58 | user.age = result.getString(result.getColumnIndex(COL_AGE)).toInt() 59 | list.add(user) 60 | }while (result.moveToNext()) 61 | } 62 | 63 | result.close() 64 | db.close() 65 | return list 66 | } 67 | 68 | fun deleteData(){ 69 | val db = this.writableDatabase 70 | db.delete(TABLE_NAME,null,null) 71 | db.close() 72 | } 73 | 74 | 75 | fun updateData() { 76 | val db = this.writableDatabase 77 | val query = "Select * from " + TABLE_NAME 78 | val result = db.rawQuery(query,null) 79 | if(result.moveToFirst()){ 80 | do { 81 | var cv = ContentValues() 82 | cv.put(COL_AGE,(result.getInt(result.getColumnIndex(COL_AGE))+1)) 83 | db.update(TABLE_NAME,cv,COL_ID + "=? AND " + COL_NAME + "=?", 84 | arrayOf(result.getString(result.getColumnIndex(COL_ID)), 85 | result.getString(result.getColumnIndex(COL_NAME)))) 86 | }while (result.moveToNext()) 87 | } 88 | 89 | result.close() 90 | db.close() 91 | } 92 | 93 | 94 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/vicky/sqliteexample/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.vicky.sqliteexample 2 | 3 | import android.support.v7.app.AppCompatActivity 4 | import android.os.Bundle 5 | import android.widget.Toast 6 | import kotlinx.android.synthetic.main.activity_main.* 7 | 8 | class MainActivity : AppCompatActivity() { 9 | 10 | override fun onCreate(savedInstanceState: Bundle?) { 11 | super.onCreate(savedInstanceState) 12 | setContentView(R.layout.activity_main) 13 | 14 | val context = this 15 | var db = DataBaseHandler(context) 16 | btn_insert.setOnClickListener({ 17 | if (etvName.text.toString().length > 0 && 18 | etvAge.text.toString().length > 0) { 19 | var user = User(etvName.text.toString(),etvAge.text.toString().toInt()) 20 | db.insertData(user) 21 | } else { 22 | Toast.makeText(context,"Please Fill All Data's",Toast.LENGTH_SHORT).show() 23 | } 24 | }) 25 | 26 | btn_read.setOnClickListener({ 27 | var data = db.readData() 28 | tvResult.text = "" 29 | for (i in 0..(data.size - 1)) { 30 | tvResult.append(data.get(i).id.toString() + " " + data.get(i).name + " " + data.get(i).age + "\n") 31 | } 32 | }) 33 | 34 | btn_update.setOnClickListener({ 35 | db.updateData() 36 | btn_read.performClick() 37 | }) 38 | 39 | btn_delete.setOnClickListener({ 40 | db.deleteData() 41 | btn_read.performClick() 42 | }) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/vicky/sqliteexample/User.kt: -------------------------------------------------------------------------------- 1 | package com.example.vicky.sqliteexample 2 | 3 | /** 4 | * Created by VickY on 2017-11-28. 5 | */ 6 | 7 | class User{ 8 | 9 | var id : Int = 0 10 | var name : String = "" 11 | var age : Int = 0 12 | 13 | constructor(name:String,age:Int){ 14 | this.name = name 15 | this.age = age 16 | } 17 | 18 | constructor(){ 19 | } 20 | 21 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 15 | 21 | 22 | 29 | 30 |