File tree 4 files changed +57
-4
lines changed
src/main/java/com/amit/db
4 files changed +57
-4
lines changed Original file line number Diff line number Diff line change @@ -15,8 +15,8 @@ android {
15
15
defaultConfig {
16
16
minSdkVersion 19
17
17
targetSdkVersion 28
18
- versionCode 36 // this indicates the number of releases of library
19
- versionName " 1.4.0 " // this indicates the current version of library
18
+ versionCode 42 // this indicates the number of releases of library
19
+ versionName " 1.6.3 " // this indicates the current version of library
20
20
}
21
21
22
22
buildTypes {
Original file line number Diff line number Diff line change @@ -992,6 +992,59 @@ public DBHelper createTable(String tableName)
992
992
993
993
return this ;
994
994
}
995
+
996
+ //#region COMMENTS FOR alterTable method
997
+ /**
998
+ * 2019 April 15 - Monday - 01:13 PM
999
+ * alter table method
1000
+ *
1001
+ * @param tableName - name of the table where column is to be added
1002
+ *
1003
+ * this method will alter the table and will add new column to the table
1004
+ **/
1005
+ //#endregion COMMENTS FOR alterTable method
1006
+ public DBHelper alterTable (String tableName )
1007
+ {
1008
+ try
1009
+ {
1010
+ if (dbColumnArrayList == null || dbColumnArrayList .size () == 0 )
1011
+ {
1012
+ Log .e (TAG , "alterTable: No Db Columns were provided." );
1013
+ return this ;
1014
+ }
1015
+
1016
+ for (int i = 0 ; i < dbColumnArrayList .size (); i ++)
1017
+ {
1018
+ String columnName = dbColumnArrayList .get (i ).columnName ;
1019
+ String columnDataType = dbColumnArrayList .get (i ).columnDataType ;
1020
+
1021
+ String query = "SELECT COUNT(*) FROM pragma_table_info('" + tableName + "') " +
1022
+ "WHERE name = '" + columnName + "'" ;
1023
+
1024
+ int count = db .getRecordCount (query );
1025
+
1026
+ if (count == 0 )
1027
+ {
1028
+ query = "ALTER TABLE " + tableName + " ADD COLUMN " + columnName + " " + columnDataType ;
1029
+ Log .e (TAG , "alterTable: query for adding new column or altering table is: " + query );
1030
+ db .getWritableDatabase ().execSQL (query );
1031
+ }
1032
+ else
1033
+ {
1034
+ Log .e (TAG , "alterTable: " + columnName + " already exists in " + tableName );
1035
+ }
1036
+ }
1037
+
1038
+ return this ;
1039
+ }
1040
+ catch (Exception e )
1041
+ {
1042
+ Log .e (TAG , "alterTable: exception while altering table:\n " );
1043
+ e .printStackTrace ();
1044
+
1045
+ return null ;
1046
+ }
1047
+ }
995
1048
996
1049
//#region COMMENTS FOR insertData method
997
1050
/**
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
3
3
buildscript {
4
- ext. kotlinVersion = ' 1.3.21 '
4
+ ext. kotlinVersion = ' 1.3.30 '
5
5
ext. supportLibraryVersion = ' 28.0.0'
6
6
7
7
repositories {
@@ -10,7 +10,7 @@ buildscript {
10
10
}
11
11
12
12
dependencies {
13
- classpath ' com.android.tools.build:gradle:3.3.1 '
13
+ classpath ' com.android.tools.build:gradle:3.3.2 '
14
14
classpath ' com.github.dcendents:android-maven-gradle-plugin:2.1'
15
15
classpath " org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion "
16
16
You can’t perform that action at this time.
0 commit comments