Skip to content

Commit febb4cf

Browse files
committed
1. Updated gradle version.
2. Added new method in db helper for checking if column exists or not.
1 parent 051df35 commit febb4cf

File tree

5 files changed

+57
-8
lines changed

5 files changed

+57
-8
lines changed

.idea/caches/build_file_checksums.ser

0 Bytes
Binary file not shown.

app/build.gradle

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ group = 'com.github.amitjangid80'
1010

1111
android {
1212
compileSdkVersion 28
13-
buildToolsVersion "28.0.3"
1413

1514
defaultConfig {
1615
minSdkVersion 19
@@ -49,11 +48,11 @@ dependencies {
4948
implementation "com.android.support:appcompat-v7:$supportLibraryVersion"
5049
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
5150

52-
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.1'
53-
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.0.0'
51+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2'
52+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.2'
5453

5554
// RxJava dependencies
56-
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
55+
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
5756

5857
// kotlin dependencies
5958
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion"

app/src/main/java/com/amit/db/DBHelper.java

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,56 @@ public boolean isTableExists(String tableName)
797797
}
798798
}
799799

800+
/**
801+
* 2019 November 19 - Tuesday - 12:49 PM
802+
* check if column exists method
803+
*
804+
* this method will check if a column in a table exists or not
805+
*
806+
* @param tableName - table name to check for column name
807+
*
808+
* @param columnName - column name to check if exists or not
809+
*
810+
* @return returns true if column exists in table or false if not
811+
**/
812+
private boolean checkIsColumnExists(String tableName, String columnName)
813+
{
814+
try
815+
{
816+
boolean isExists = false;
817+
818+
String query = "PRAGMA TABLE_INFO('" + tableName + "')";
819+
Cursor cursor = db.getWritableDatabase().rawQuery(query, null);
820+
821+
if (cursor != null && cursor.moveToFirst())
822+
{
823+
for (int i = 0; i < cursor.getCount(); i++)
824+
{
825+
String currentColumnName = cursor.getString(cursor.getColumnIndex("name"));
826+
827+
if (currentColumnName.equalsIgnoreCase(columnName))
828+
{
829+
isExists = true;
830+
Log.e(TAG, "checkIsColumnExists: " + columnName + " found in table " + tableName);
831+
}
832+
833+
cursor.moveToNext();
834+
}
835+
836+
cursor.close();
837+
}
838+
839+
return isExists;
840+
}
841+
catch (Exception e)
842+
{
843+
Log.e(TAG, "checkIsColumnExists: exception while checking if column exists or not\n");
844+
e.printStackTrace();
845+
846+
return false;
847+
}
848+
}
849+
800850
//#region COMMENTS FOR getMaxId method
801851
/**
802852
* 2018 August 13 - Monday - 12:34 PM

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22

33
buildscript {
4-
ext.kotlinVersion = '1.3.41'
4+
ext.kotlinVersion = '1.3.60'
55
ext.supportLibraryVersion = '28.0.0'
66

77
repositories {
@@ -10,7 +10,7 @@ buildscript {
1010
}
1111

1212
dependencies {
13-
classpath 'com.android.tools.build:gradle:3.4.2'
13+
classpath 'com.android.tools.build:gradle:3.5.2'
1414
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
1515
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
1616

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Wed Jun 12 16:30:54 IST 2019
1+
#Wed Oct 16 12:44:32 IST 2019
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

0 commit comments

Comments
 (0)