diff --git a/CHANGELOG.md b/CHANGELOG.md index dcdfbf1..27b7bb9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,22 @@ Change Log ========== +Version 1.0.6 *(2019-03-07)* +---------------------------- + +* Fix: Fix query error +* Fix: Fix DebugDb class not found error + + +Version 1.0.5 *(2019-02-18)* +---------------------------- + +* Reduce size by taking out encrypted database library as a separate module +* New: Add support for database delete +* Changed compile to implementation +* Fix: Minor bug fixes + + Version 1.0.4 *(2018-06-23)* ---------------------------- @@ -48,7 +64,7 @@ Version 0.5.0 *(2017-01-21)* * New: Export DB * New: Method to get DB version -* Fix: Fix prouard issue and other minor issues +* Fix: Fix proguard issue and other minor issues Version 0.4.0 *(2016-11-29)* diff --git a/README.md b/README.md index e3cd36f..41ef88c 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,13 @@ Add this to your app's build.gradle ```groovy -debugImplementation 'com.amitshekhar.android:debug-db:1.0.4' +debugImplementation 'com.amitshekhar.android:debug-db:1.0.6' +``` + +Using the Android Debug Database with encrypted database + +```groovy +debugImplementation 'com.amitshekhar.android:debug-db-encrypt:1.0.6' ``` Use `debugImplementation` so that it will only compile in your debug build and not in your release build. diff --git a/build.gradle b/build.gradle index 7153aea..d2353ea 100644 --- a/build.gradle +++ b/build.gradle @@ -23,7 +23,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.3.0' + classpath 'com.android.tools.build:gradle:3.3.1' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4' classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' } diff --git a/debug-db-base/build.gradle b/debug-db-base/build.gradle index 48b8e85..db2510f 100644 --- a/debug-db-base/build.gradle +++ b/debug-db-base/build.gradle @@ -39,12 +39,10 @@ android { dependencies { implementation 'com.google.code.gson:gson:2.8.5' - implementation 'net.zetetic:android-database-sqlcipher:3.5.9' implementation 'android.arch.persistence.room:runtime:1.1.1' - implementation 'com.android.support:appcompat-v7:28.0.0' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' } -//apply from: 'debug-db-upload.gradle' +//apply from: 'debug-db-base-upload.gradle' diff --git a/debug-db-base/debug-db-base-upload.gradle b/debug-db-base/debug-db-base-upload.gradle new file mode 100755 index 0000000..62d53ba --- /dev/null +++ b/debug-db-base/debug-db-base-upload.gradle @@ -0,0 +1,104 @@ +/* + * + * * Copyright (C) 2019 Amit Shekhar + * * Copyright (C) 2011 Android Open Source Project + * * + * * Licensed under the Apache License, Version 2.0 (the "License"); + * * you may not use this file except in compliance with the License. + * * You may obtain a copy of the License at + * * + * * http://www.apache.org/licenses/LICENSE-2.0 + * * + * * Unless required by applicable law or agreed to in writing, software + * * distributed under the License is distributed on an "AS IS" BASIS, + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * See the License for the specific language governing permissions and + * * limitations under the License. + * + */ + +apply plugin: 'com.github.dcendents.android-maven' +apply plugin: "com.jfrog.bintray" + +def siteUrl = 'https://github.com/amitshekhariitbhu/Android-Debug-Database' +def gitUrl = 'https://github.com/amitshekhariitbhu/Android-Debug-Database.git' + +group = "com.amitshekhar.android" +version = '1.0.6' + +install { + repositories.mavenInstaller { + pom.project { + packaging 'aar' + + name 'Android Debug Database' + description 'Android Debug Database is a powerful library for debugging databases in Android applications' + + url siteUrl + + licenses { + license { + name 'The Apache Software License, Version 2.0' + url 'http://www.apache.org/licenses/LICENSE-2.0.txt' + } + } + + developers { + developer { + id 'amitshekhariitbhu' + name 'Amit Shekhar' + email 'amit.shekhar.iitbhu@gmail.com' + } + } + + scm { + connection gitUrl + developerConnection gitUrl + url siteUrl + } + } + } +} + +task sourcesJar(type: Jar) { + from android.sourceSets.main.java.srcDirs + classifier = 'sources' +} + +task javadoc(type: Javadoc) { + source = android.sourceSets.main.java.srcDirs + failOnError false + classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) + classpath += configurations.compile +} + +task javadocJar(type: Jar, dependsOn: javadoc) { + classifier = 'javadoc' + from javadoc.destinationDir +} +artifacts { + archives javadocJar + archives sourcesJar +} + +if (project.rootProject.file("local.properties").exists()) { + Properties properties = new Properties() + properties.load(project.rootProject.file('local.properties').newDataInputStream()) + + bintray { + user = properties.getProperty("bintray.user") + key = properties.getProperty("bintray.apikey") + + configurations = ['archives'] + dryRun = false + + pkg { + repo = "maven" + name = "debug-db-base" + websiteUrl = siteUrl + vcsUrl = gitUrl + licenses = ["Apache-2.0"] + publish = true + } + } +} diff --git a/debug-db-base/src/main/java/com/amitshekhar/DebugDB.java b/debug-db-base/src/main/java/com/amitshekhar/DebugDB.java index 66a8f64..d891525 100644 --- a/debug-db-base/src/main/java/com/amitshekhar/DebugDB.java +++ b/debug-db-base/src/main/java/com/amitshekhar/DebugDB.java @@ -25,6 +25,7 @@ import android.util.Pair; import com.amitshekhar.server.ClientServer; +import com.amitshekhar.sqlite.DBFactory; import com.amitshekhar.utils.NetworkUtils; import java.io.File; @@ -45,7 +46,7 @@ private DebugDB() { // This class in not publicly instantiable } - public static void initialize(Context context) { + public static void initialize(Context context, DBFactory dbFactory) { int portNumber; try { @@ -56,7 +57,7 @@ public static void initialize(Context context) { Log.i(TAG, "Using Default port : " + DEFAULT_PORT); } - clientServer = new ClientServer(context, portNumber); + clientServer = new ClientServer(context, portNumber, dbFactory); clientServer.start(); addressLog = NetworkUtils.getAddressLog(context, portNumber); Log.d(TAG, addressLog); diff --git a/debug-db-base/src/main/java/com/amitshekhar/server/ClientServer.java b/debug-db-base/src/main/java/com/amitshekhar/server/ClientServer.java index ded3f4e..151307d 100644 --- a/debug-db-base/src/main/java/com/amitshekhar/server/ClientServer.java +++ b/debug-db-base/src/main/java/com/amitshekhar/server/ClientServer.java @@ -23,12 +23,13 @@ * Created by amitshekhar on 15/11/16. */ - import android.arch.persistence.db.SupportSQLiteDatabase; import android.content.Context; import android.util.Log; import android.util.Pair; +import com.amitshekhar.sqlite.DBFactory; + import java.io.File; import java.io.IOException; import java.net.ServerSocket; @@ -45,8 +46,8 @@ public class ClientServer implements Runnable { private boolean mIsRunning; private ServerSocket mServerSocket; - public ClientServer(Context context, int port) { - mRequestHandler = new RequestHandler(context); + public ClientServer(Context context, int port, DBFactory dbFactory) { + mRequestHandler = new RequestHandler(context, dbFactory); mPort = port; } diff --git a/debug-db-base/src/main/java/com/amitshekhar/server/RequestHandler.java b/debug-db-base/src/main/java/com/amitshekhar/server/RequestHandler.java index 1285ab4..709a19c 100644 --- a/debug-db-base/src/main/java/com/amitshekhar/server/RequestHandler.java +++ b/debug-db-base/src/main/java/com/amitshekhar/server/RequestHandler.java @@ -30,7 +30,7 @@ import com.amitshekhar.model.RowDataRequest; import com.amitshekhar.model.TableDataResponse; import com.amitshekhar.model.UpdateRowResponse; -import com.amitshekhar.sqlite.DebugSQLiteDB; +import com.amitshekhar.sqlite.DBFactory; import com.amitshekhar.sqlite.InMemoryDebugSQLiteDB; import com.amitshekhar.sqlite.SQLiteDB; import com.amitshekhar.utils.Constants; @@ -42,8 +42,6 @@ import com.google.gson.GsonBuilder; import com.google.gson.reflect.TypeToken; -import net.sqlcipher.database.SQLiteDatabase; - import java.io.BufferedReader; import java.io.File; import java.io.IOException; @@ -63,6 +61,7 @@ public class RequestHandler { private final Context mContext; private final Gson mGson; private final AssetManager mAssets; + private final DBFactory mDbFactory; private boolean isDbOpened; private SQLiteDB sqLiteDB; private HashMap> mDatabaseFiles; @@ -70,10 +69,11 @@ public class RequestHandler { private String mSelectedDatabase = null; private HashMap mRoomInMemoryDatabases = new HashMap<>(); - public RequestHandler(Context context) { + public RequestHandler(Context context, DBFactory dbFactory) { mContext = context; mAssets = context.getResources().getAssets(); mGson = new GsonBuilder().serializeNulls().create(); + mDbFactory = dbFactory; } public void handle(Socket socket) throws IOException { @@ -184,8 +184,7 @@ private void openDatabase(String database) { } else { File databaseFile = mDatabaseFiles.get(database).first; String password = mDatabaseFiles.get(database).second; - SQLiteDatabase.loadLibs(mContext); - sqLiteDB = new DebugSQLiteDB(SQLiteDatabase.openOrCreateDatabase(databaseFile.getAbsolutePath(), password, null)); + sqLiteDB = mDbFactory.create(mContext, databaseFile.getAbsolutePath(), password); } isDbOpened = true; } diff --git a/debug-db-base/src/main/java/com/amitshekhar/sqlite/DBFactory.java b/debug-db-base/src/main/java/com/amitshekhar/sqlite/DBFactory.java new file mode 100644 index 0000000..0378184 --- /dev/null +++ b/debug-db-base/src/main/java/com/amitshekhar/sqlite/DBFactory.java @@ -0,0 +1,9 @@ +package com.amitshekhar.sqlite; + +import android.content.Context; + +public interface DBFactory { + + SQLiteDB create(Context context, String path, String password); + +} diff --git a/debug-db-base/src/main/java/com/amitshekhar/utils/DatabaseHelper.java b/debug-db-base/src/main/java/com/amitshekhar/utils/DatabaseHelper.java index 4acaf9a..adf36e6 100644 --- a/debug-db-base/src/main/java/com/amitshekhar/utils/DatabaseHelper.java +++ b/debug-db-base/src/main/java/com/amitshekhar/utils/DatabaseHelper.java @@ -124,6 +124,25 @@ public static TableDataResponse getTableData(SQLiteDB db, String selectQuery, St tableData.isSuccessful = true; tableData.rows = new ArrayList<>(); + + String[] columnNames = cursor.getColumnNames(); + + List tableInfoListModified = new ArrayList<>(); + + for (String columnName : columnNames) { + for (TableDataResponse.TableInfo tableInfo : tableData.tableInfos) { + if (columnName.equals(tableInfo.title)) { + tableInfoListModified.add(tableInfo); + break; + } + } + } + + if (tableData.tableInfos.size() != tableInfoListModified.size()) { + tableData.tableInfos = tableInfoListModified; + tableData.isEditable = false; + } + if (cursor.getCount() > 0) { do { diff --git a/debug-db-encrypt/build.gradle b/debug-db-encrypt/build.gradle index d76d484..ab7d87a 100644 --- a/debug-db-encrypt/build.gradle +++ b/debug-db-encrypt/build.gradle @@ -18,8 +18,11 @@ android { } dependencies { - implementation project(':debug-db-base') + api project(':debug-db-base') + implementation 'net.zetetic:android-database-sqlcipher:3.5.9' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' } + +//apply from: 'debug-db-encrypt-upload.gradle' \ No newline at end of file diff --git a/debug-db-encrypt/debug-db-encrypt-upload.gradle b/debug-db-encrypt/debug-db-encrypt-upload.gradle new file mode 100755 index 0000000..6f60e6a --- /dev/null +++ b/debug-db-encrypt/debug-db-encrypt-upload.gradle @@ -0,0 +1,104 @@ +/* + * + * * Copyright (C) 2019 Amit Shekhar + * * Copyright (C) 2011 Android Open Source Project + * * + * * Licensed under the Apache License, Version 2.0 (the "License"); + * * you may not use this file except in compliance with the License. + * * You may obtain a copy of the License at + * * + * * http://www.apache.org/licenses/LICENSE-2.0 + * * + * * Unless required by applicable law or agreed to in writing, software + * * distributed under the License is distributed on an "AS IS" BASIS, + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * See the License for the specific language governing permissions and + * * limitations under the License. + * + */ + +apply plugin: 'com.github.dcendents.android-maven' +apply plugin: "com.jfrog.bintray" + +def siteUrl = 'https://github.com/amitshekhariitbhu/Android-Debug-Database' +def gitUrl = 'https://github.com/amitshekhariitbhu/Android-Debug-Database.git' + +group = "com.amitshekhar.android" +version = '1.0.6' + +install { + repositories.mavenInstaller { + pom.project { + packaging 'aar' + + name 'Android Debug Database' + description 'Android Debug Database is a powerful library for debugging databases in Android applications' + + url siteUrl + + licenses { + license { + name 'The Apache Software License, Version 2.0' + url 'http://www.apache.org/licenses/LICENSE-2.0.txt' + } + } + + developers { + developer { + id 'amitshekhariitbhu' + name 'Amit Shekhar' + email 'amit.shekhar.iitbhu@gmail.com' + } + } + + scm { + connection gitUrl + developerConnection gitUrl + url siteUrl + } + } + } +} + +task sourcesJar(type: Jar) { + from android.sourceSets.main.java.srcDirs + classifier = 'sources' +} + +task javadoc(type: Javadoc) { + source = android.sourceSets.main.java.srcDirs + failOnError false + classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) + classpath += configurations.compile +} + +task javadocJar(type: Jar, dependsOn: javadoc) { + classifier = 'javadoc' + from javadoc.destinationDir +} +artifacts { + archives javadocJar + archives sourcesJar +} + +if (project.rootProject.file("local.properties").exists()) { + Properties properties = new Properties() + properties.load(project.rootProject.file('local.properties').newDataInputStream()) + + bintray { + user = properties.getProperty("bintray.user") + key = properties.getProperty("bintray.apikey") + + configurations = ['archives'] + dryRun = false + + pkg { + repo = "maven" + name = "debug-db-encrypt" + websiteUrl = siteUrl + vcsUrl = gitUrl + licenses = ["Apache-2.0"] + publish = true + } + } +} diff --git a/debug-db-encrypt/src/main/java/com/amitshekhar/debug/encrypt/DebugDBEncryptInitProvider.java b/debug-db-encrypt/src/main/java/com/amitshekhar/debug/encrypt/DebugDBEncryptInitProvider.java index e3c5d68..9403b4f 100644 --- a/debug-db-encrypt/src/main/java/com/amitshekhar/debug/encrypt/DebugDBEncryptInitProvider.java +++ b/debug-db-encrypt/src/main/java/com/amitshekhar/debug/encrypt/DebugDBEncryptInitProvider.java @@ -8,6 +8,7 @@ import android.net.Uri; import com.amitshekhar.DebugDB; +import com.amitshekhar.debug.encrypt.sqlite.DebugDBEncryptFactory; public class DebugDBEncryptInitProvider extends ContentProvider { @@ -17,7 +18,7 @@ public DebugDBEncryptInitProvider() { @Override public boolean onCreate() { - DebugDB.initialize(getContext()); + DebugDB.initialize(getContext(), new DebugDBEncryptFactory()); return true; } diff --git a/debug-db-encrypt/src/main/java/com/amitshekhar/debug/encrypt/sqlite/DebugDBEncryptFactory.java b/debug-db-encrypt/src/main/java/com/amitshekhar/debug/encrypt/sqlite/DebugDBEncryptFactory.java new file mode 100644 index 0000000..af0294a --- /dev/null +++ b/debug-db-encrypt/src/main/java/com/amitshekhar/debug/encrypt/sqlite/DebugDBEncryptFactory.java @@ -0,0 +1,18 @@ +package com.amitshekhar.debug.encrypt.sqlite; + +import android.content.Context; + +import com.amitshekhar.sqlite.DBFactory; +import com.amitshekhar.sqlite.SQLiteDB; + +import net.sqlcipher.database.SQLiteDatabase; + +public class DebugDBEncryptFactory implements DBFactory { + + @Override + public SQLiteDB create(Context context, String path, String password) { + SQLiteDatabase.loadLibs(context); + return new DebugEncryptSQLiteDB(SQLiteDatabase.openOrCreateDatabase(path, password, null)); + } + +} diff --git a/debug-db-encrypt/src/main/java/com/amitshekhar/debug/encrypt/sqlite/DebugEncryptSQLiteDB.java b/debug-db-encrypt/src/main/java/com/amitshekhar/debug/encrypt/sqlite/DebugEncryptSQLiteDB.java new file mode 100644 index 0000000..5c387cb --- /dev/null +++ b/debug-db-encrypt/src/main/java/com/amitshekhar/debug/encrypt/sqlite/DebugEncryptSQLiteDB.java @@ -0,0 +1,62 @@ +package com.amitshekhar.debug.encrypt.sqlite; + +import android.content.ContentValues; +import android.database.Cursor; +import android.database.SQLException; + +import com.amitshekhar.sqlite.SQLiteDB; + +import net.sqlcipher.database.SQLiteDatabase; + +/** + * Created by anandgaurav on 12/02/18. + */ + +public class DebugEncryptSQLiteDB implements SQLiteDB { + + private final SQLiteDatabase database; + + public DebugEncryptSQLiteDB(SQLiteDatabase database) { + this.database = database; + } + + @Override + public int delete(String table, String whereClause, String[] whereArgs) { + return database.delete(table, whereClause, whereArgs); + } + + @Override + public boolean isOpen() { + return database.isOpen(); + } + + @Override + public void close() { + database.close(); + } + + @Override + public Cursor rawQuery(String sql, String[] selectionArgs) { + return database.rawQuery(sql, selectionArgs); + } + + @Override + public void execSQL(String sql) throws SQLException { + database.execSQL(sql); + } + + @Override + public long insert(String table, String nullColumnHack, ContentValues values) { + return database.insert(table, nullColumnHack, values); + } + + @Override + public int update(String table, ContentValues values, String whereClause, String[] whereArgs) { + return database.update(table, values, whereClause, whereArgs); + } + + @Override + public int getVersion() { + return database.getVersion(); + } +} diff --git a/debug-db/build.gradle b/debug-db/build.gradle index d76d484..c6f76ed 100644 --- a/debug-db/build.gradle +++ b/debug-db/build.gradle @@ -18,8 +18,10 @@ android { } dependencies { - implementation project(':debug-db-base') + api project(':debug-db-base') testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' } + +//apply from: 'debug-db-upload.gradle' \ No newline at end of file diff --git a/debug-db-base/debug-db-upload.gradle b/debug-db/debug-db-upload.gradle similarity index 98% rename from debug-db-base/debug-db-upload.gradle rename to debug-db/debug-db-upload.gradle index 9c4769a..b4dfd79 100755 --- a/debug-db-base/debug-db-upload.gradle +++ b/debug-db/debug-db-upload.gradle @@ -24,7 +24,7 @@ def siteUrl = 'https://github.com/amitshekhariitbhu/Android-Debug-Database' def gitUrl = 'https://github.com/amitshekhariitbhu/Android-Debug-Database.git' group = "com.amitshekhar.android" -version = '1.0.4' +version = '1.0.6' install { repositories.mavenInstaller { @@ -67,6 +67,7 @@ task sourcesJar(type: Jar) { task javadoc(type: Javadoc) { source = android.sourceSets.main.java.srcDirs + failOnError false classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) classpath += configurations.compile } diff --git a/debug-db/src/main/java/com/amitshekhar/debug/DebugDBInitProvider.java b/debug-db/src/main/java/com/amitshekhar/debug/DebugDBInitProvider.java index 6cea096..d9d88c1 100644 --- a/debug-db/src/main/java/com/amitshekhar/debug/DebugDBInitProvider.java +++ b/debug-db/src/main/java/com/amitshekhar/debug/DebugDBInitProvider.java @@ -27,6 +27,7 @@ import android.net.Uri; import com.amitshekhar.DebugDB; +import com.amitshekhar.debug.sqlite.DebugDBFactory; /** * Created by amitshekhar on 16/11/16. @@ -40,7 +41,7 @@ public DebugDBInitProvider() { @Override public boolean onCreate() { - DebugDB.initialize(getContext()); + DebugDB.initialize(getContext(), new DebugDBFactory()); return true; } diff --git a/debug-db/src/main/java/com/amitshekhar/debug/sqlite/DebugDBFactory.java b/debug-db/src/main/java/com/amitshekhar/debug/sqlite/DebugDBFactory.java new file mode 100644 index 0000000..3a797f5 --- /dev/null +++ b/debug-db/src/main/java/com/amitshekhar/debug/sqlite/DebugDBFactory.java @@ -0,0 +1,16 @@ +package com.amitshekhar.debug.sqlite; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; + +import com.amitshekhar.sqlite.DBFactory; +import com.amitshekhar.sqlite.SQLiteDB; + +public class DebugDBFactory implements DBFactory { + + @Override + public SQLiteDB create(Context context, String path, String password) { + return new DebugSQLiteDB(SQLiteDatabase.openOrCreateDatabase(path, null)); + } + +} diff --git a/debug-db-base/src/main/java/com/amitshekhar/sqlite/DebugSQLiteDB.java b/debug-db/src/main/java/com/amitshekhar/debug/sqlite/DebugSQLiteDB.java similarity index 91% rename from debug-db-base/src/main/java/com/amitshekhar/sqlite/DebugSQLiteDB.java rename to debug-db/src/main/java/com/amitshekhar/debug/sqlite/DebugSQLiteDB.java index 385934d..fa6512c 100644 --- a/debug-db-base/src/main/java/com/amitshekhar/sqlite/DebugSQLiteDB.java +++ b/debug-db/src/main/java/com/amitshekhar/debug/sqlite/DebugSQLiteDB.java @@ -1,14 +1,11 @@ -package com.amitshekhar.sqlite; +package com.amitshekhar.debug.sqlite; import android.content.ContentValues; import android.database.Cursor; import android.database.SQLException; +import android.database.sqlite.SQLiteDatabase; -import net.sqlcipher.database.SQLiteDatabase; - -/** - * Created by anandgaurav on 12/02/18. - */ +import com.amitshekhar.sqlite.SQLiteDB; public class DebugSQLiteDB implements SQLiteDB { diff --git a/sample-app-encrypt/.gitignore b/sample-app-encrypt/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/sample-app-encrypt/.gitignore @@ -0,0 +1 @@ +/build diff --git a/sample-app-encrypt/build.gradle b/sample-app-encrypt/build.gradle new file mode 100644 index 0000000..ae27b46 --- /dev/null +++ b/sample-app-encrypt/build.gradle @@ -0,0 +1,35 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 28 + defaultConfig { + applicationId "com.sample.encrypt" + minSdkVersion 15 + targetSdkVersion 28 + versionCode 1 + versionName "1.0" + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + + } + buildTypes { + debug { + resValue("string", "PORT_NUMBER", "8080") + resValue("string", "DB_PASSWORD_PERSON", "a_password") + } + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + debugImplementation project(':debug-db-encrypt') + implementation 'com.android.support:appcompat-v7:28.0.0' + implementation 'net.zetetic:android-database-sqlcipher:3.5.9' + implementation 'android.arch.persistence.room:runtime:1.1.1' + annotationProcessor 'android.arch.persistence.room:compiler:1.1.1' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'com.android.support.test:runner:1.0.2' + androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' +} diff --git a/app/proguard-rules.pro b/sample-app-encrypt/proguard-rules.pro similarity index 100% rename from app/proguard-rules.pro rename to sample-app-encrypt/proguard-rules.pro diff --git a/sample-app-encrypt/src/androidTest/java/com/sample/encrypt/ExampleInstrumentedTest.java b/sample-app-encrypt/src/androidTest/java/com/sample/encrypt/ExampleInstrumentedTest.java new file mode 100644 index 0000000..f9938b2 --- /dev/null +++ b/sample-app-encrypt/src/androidTest/java/com/sample/encrypt/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package com.sample.encrypt; + +import android.content.Context; +import android.support.test.InstrumentationRegistry; +import android.support.test.runner.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getTargetContext(); + + assertEquals("com.sample.encrypt", appContext.getPackageName()); + } +} diff --git a/sample-app-encrypt/src/main/AndroidManifest.xml b/sample-app-encrypt/src/main/AndroidManifest.xml new file mode 100644 index 0000000..ad21f88 --- /dev/null +++ b/sample-app-encrypt/src/main/AndroidManifest.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/sample/MainActivity.java b/sample-app-encrypt/src/main/java/com/sample/encrypt/MainActivity.java similarity index 93% rename from app/src/main/java/com/sample/MainActivity.java rename to sample-app-encrypt/src/main/java/com/sample/encrypt/MainActivity.java index 3634b36..e035da3 100644 --- a/app/src/main/java/com/sample/MainActivity.java +++ b/sample-app-encrypt/src/main/java/com/sample/encrypt/MainActivity.java @@ -17,7 +17,7 @@ * */ -package com.sample; +package com.sample.encrypt; import android.annotation.SuppressLint; import android.content.Context; @@ -27,13 +27,13 @@ import android.support.v7.app.AppCompatActivity; import android.view.View; -import com.sample.database.CarDBHelper; -import com.sample.database.ContactDBHelper; -import com.sample.database.ExtTestDBHelper; -import com.sample.database.PersonDBHelper; -import com.sample.database.room.User; -import com.sample.database.room.UserDBHelper; -import com.sample.utils.Utils; +import com.sample.encrypt.database.CarDBHelper; +import com.sample.encrypt.database.ContactDBHelper; +import com.sample.encrypt.database.ExtTestDBHelper; +import com.sample.encrypt.database.PersonDBHelper; +import com.sample.encrypt.database.room.User; +import com.sample.encrypt.database.room.UserDBHelper; +import com.sample.encrypt.utils.Utils; import java.util.ArrayList; import java.util.HashSet; diff --git a/sample-app-encrypt/src/main/java/com/sample/encrypt/database/CarDBHelper.java b/sample-app-encrypt/src/main/java/com/sample/encrypt/database/CarDBHelper.java new file mode 100644 index 0000000..c620a4d --- /dev/null +++ b/sample-app-encrypt/src/main/java/com/sample/encrypt/database/CarDBHelper.java @@ -0,0 +1,134 @@ +/* + * + * * Copyright (C) 2019 Amit Shekhar + * * Copyright (C) 2011 Android Open Source Project + * * + * * Licensed under the Apache License, Version 2.0 (the "License"); + * * you may not use this file except in compliance with the License. + * * You may obtain a copy of the License at + * * + * * http://www.apache.org/licenses/LICENSE-2.0 + * * + * * Unless required by applicable law or agreed to in writing, software + * * distributed under the License is distributed on an "AS IS" BASIS, + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * See the License for the specific language governing permissions and + * * limitations under the License. + * + */ + +package com.sample.encrypt.database; + +import android.content.ContentValues; +import android.content.Context; +import android.database.Cursor; +import android.database.DatabaseUtils; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteOpenHelper; + +import java.util.ArrayList; + +/** + * Created by amitshekhar on 06/02/17. + */ + +public class CarDBHelper extends SQLiteOpenHelper { + + public static final String DATABASE_NAME = "Car.db"; + public static final String CARS_TABLE_NAME = "cars"; + public static final String CARS_COLUMN_ID = "id"; + public static final String CARS_COLUMN_NAME = "name"; + public static final String CARS_COLUMN_COLOR = "color"; + public static final String CCARS_COLUMN_MILEAGE = "mileage"; + + public CarDBHelper(Context context) { + super(context, DATABASE_NAME, null, 1); + } + + @Override + public void onCreate(SQLiteDatabase db) { + // TODO Auto-generated method stub + db.execSQL( + "create table cars " + + "(id integer primary key, name text, color text, mileage real)" + ); + + db.execSQL("create table [transaction] (id integer primary key, name text)"); + + for (int i = 0; i < 10; i++) { + db.execSQL("insert into [transaction] (name) values ('hello');"); + } + } + + @Override + public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { + // TODO Auto-generated method stub + db.execSQL("DROP TABLE IF EXISTS cars"); + onCreate(db); + } + + public boolean insertCar(String name, String color, float mileage) { + SQLiteDatabase db = this.getWritableDatabase(); + ContentValues contentValues = new ContentValues(); + contentValues.put("name", name); + contentValues.put("color", color); + contentValues.put("mileage", mileage); + db.insert("cars", null, contentValues); + return true; + } + + public Cursor getData(int id) { + SQLiteDatabase db = this.getReadableDatabase(); + Cursor res = db.rawQuery("select * from cars where id=" + id + "", null); + return res; + } + + public int numberOfRows() { + SQLiteDatabase db = this.getReadableDatabase(); + int numRows = (int) DatabaseUtils.queryNumEntries(db, CARS_TABLE_NAME); + return numRows; + } + + public boolean updateCar(Integer id, String name, String color, float mileage) { + SQLiteDatabase db = this.getWritableDatabase(); + ContentValues contentValues = new ContentValues(); + contentValues.put("name", name); + contentValues.put("color", color); + contentValues.put("mileage", mileage); + db.update("cars", contentValues, "id = ? ", new String[]{Integer.toString(id)}); + return true; + } + + public Integer deleteCar(Integer id) { + SQLiteDatabase db = this.getWritableDatabase(); + return db.delete("cars", + "id = ? ", + new String[]{Integer.toString(id)}); + } + + public ArrayList getAllCars() { + ArrayList arrayList = new ArrayList<>(); + + //hp = new HashMap(); + SQLiteDatabase db = this.getReadableDatabase(); + Cursor res = db.rawQuery("select * from cars", null); + res.moveToFirst(); + + while (!res.isAfterLast()) { + arrayList.add(res.getString(res.getColumnIndex(CARS_COLUMN_NAME))); + res.moveToNext(); + } + return arrayList; + } + + public int count() { + SQLiteDatabase db = getReadableDatabase(); + Cursor cursor = db.rawQuery("select * from cars", null); + if (cursor != null && cursor.getCount() > 0) { + cursor.moveToFirst(); + return cursor.getInt(0); + } else { + return 0; + } + } +} diff --git a/sample-app-encrypt/src/main/java/com/sample/encrypt/database/ContactDBHelper.java b/sample-app-encrypt/src/main/java/com/sample/encrypt/database/ContactDBHelper.java new file mode 100644 index 0000000..b0f4ef3 --- /dev/null +++ b/sample-app-encrypt/src/main/java/com/sample/encrypt/database/ContactDBHelper.java @@ -0,0 +1,136 @@ +/* + * + * * Copyright (C) 2019 Amit Shekhar + * * Copyright (C) 2011 Android Open Source Project + * * + * * Licensed under the Apache License, Version 2.0 (the "License"); + * * you may not use this file except in compliance with the License. + * * You may obtain a copy of the License at + * * + * * http://www.apache.org/licenses/LICENSE-2.0 + * * + * * Unless required by applicable law or agreed to in writing, software + * * distributed under the License is distributed on an "AS IS" BASIS, + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * See the License for the specific language governing permissions and + * * limitations under the License. + * + */ + +package com.sample.encrypt.database; + +import android.content.ContentValues; +import android.content.Context; +import android.database.Cursor; +import android.database.DatabaseUtils; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteOpenHelper; + +import java.util.ArrayList; +import java.util.Calendar; + +/** + * Created by amitshekhar on 16/11/16. + */ +public class ContactDBHelper extends SQLiteOpenHelper { + + public static final String DATABASE_NAME = "Contact.db"; + public static final String CONTACTS_TABLE_NAME = "contacts"; + public static final String CONTACTS_COLUMN_ID = "id"; + public static final String CONTACTS_COLUMN_NAME = "name"; + public static final String CONTACTS_COLUMN_EMAIL = "email"; + public static final String CONTACTS_COLUMN_STREET = "street"; + public static final String CONTACTS_COLUMN_CITY = "place"; + public static final String CONTACTS_COLUMN_PHONE = "phone"; + public static final String CONTACTS_CREATED_AT = "createdAt"; + + public ContactDBHelper(Context context) { + super(context, DATABASE_NAME, null, 1); + } + + @Override + public void onCreate(SQLiteDatabase db) { + // TODO Auto-generated method stub + db.execSQL( + "create table contacts " + + "(id integer primary key, name text, phone text, email text, street text, place text, createdAt integer)" + ); + } + + @Override + public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { + // TODO Auto-generated method stub + db.execSQL("DROP TABLE IF EXISTS contacts"); + onCreate(db); + } + + public boolean insertContact(String name, String phone, String email, String street, String place) { + SQLiteDatabase db = this.getWritableDatabase(); + ContentValues contentValues = new ContentValues(); + contentValues.put("name", name); + contentValues.put("phone", phone); + contentValues.put("email", email); + contentValues.put("street", street); + contentValues.put("place", place); + contentValues.put(CONTACTS_CREATED_AT, Calendar.getInstance().getTimeInMillis()); + db.insert("contacts", null, contentValues); + return true; + } + + public Cursor getData(int id) { + SQLiteDatabase db = this.getReadableDatabase(); + Cursor res = db.rawQuery("select * from contacts where id=" + id + "", null); + return res; + } + + public int numberOfRows() { + SQLiteDatabase db = this.getReadableDatabase(); + int numRows = (int) DatabaseUtils.queryNumEntries(db, CONTACTS_TABLE_NAME); + return numRows; + } + + public boolean updateContact(Integer id, String name, String phone, String email, String street, String place) { + SQLiteDatabase db = this.getWritableDatabase(); + ContentValues contentValues = new ContentValues(); + contentValues.put("name", name); + contentValues.put("phone", phone); + contentValues.put("email", email); + contentValues.put("street", street); + contentValues.put("place", place); + db.update("contacts", contentValues, "id = ? ", new String[]{Integer.toString(id)}); + return true; + } + + public Integer deleteContact(Integer id) { + SQLiteDatabase db = this.getWritableDatabase(); + return db.delete("contacts", + "id = ? ", + new String[]{Integer.toString(id)}); + } + + public ArrayList getAllCotacts() { + ArrayList arrayList = new ArrayList<>(); + + //hp = new HashMap(); + SQLiteDatabase db = this.getReadableDatabase(); + Cursor res = db.rawQuery("select * from contacts", null); + res.moveToFirst(); + + while (!res.isAfterLast()) { + arrayList.add(res.getString(res.getColumnIndex(CONTACTS_COLUMN_NAME))); + res.moveToNext(); + } + return arrayList; + } + + public int count() { + SQLiteDatabase db = getReadableDatabase(); + Cursor cursor = db.rawQuery("select * from contacts", null); + if (cursor != null && cursor.getCount() > 0) { + cursor.moveToFirst(); + return cursor.getInt(0); + } else { + return 0; + } + } +} diff --git a/sample-app-encrypt/src/main/java/com/sample/encrypt/database/ExtTestDBHelper.java b/sample-app-encrypt/src/main/java/com/sample/encrypt/database/ExtTestDBHelper.java new file mode 100644 index 0000000..582a9f3 --- /dev/null +++ b/sample-app-encrypt/src/main/java/com/sample/encrypt/database/ExtTestDBHelper.java @@ -0,0 +1,92 @@ +package com.sample.encrypt.database; + +import android.content.ContentValues; +import android.content.Context; +import android.content.ContextWrapper; +import android.database.Cursor; +import android.database.DatabaseErrorHandler; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteOpenHelper; + +import java.io.File; +import java.util.Calendar; + +public class ExtTestDBHelper extends SQLiteOpenHelper { + + public static final String DIR_NAME = "custom_dir"; + public static final String DATABASE_NAME = "ExtTest.db"; + public static final String TEST_TABLE_NAME = "test"; + public static final String TEST_ID = "id"; + public static final String TEST_COLUMN_VALUE = "value"; + public static final String TEST_CREATED_AT = "createdAt"; + + public ExtTestDBHelper(Context context) { + super(new CustomDatabasePathContext(context), DATABASE_NAME, null, 1); + } + + @Override + public void onCreate(SQLiteDatabase db) { + // TODO Auto-generated method stub + db.execSQL( + String.format( + "create table %s (%s integer primary key, %s text, %s integer)", + TEST_TABLE_NAME, + TEST_ID, + TEST_COLUMN_VALUE, + TEST_CREATED_AT + ) + ); + } + + @Override + public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { + // TODO Auto-generated method stub + db.execSQL("DROP TABLE IF EXISTS " + TEST_TABLE_NAME); + onCreate(db); + } + + public boolean insertTest(String value) { + SQLiteDatabase db = this.getWritableDatabase(); + ContentValues contentValues = new ContentValues(); + contentValues.put("value", value); + contentValues.put(TEST_CREATED_AT, Calendar.getInstance().getTimeInMillis()); + db.insert(TEST_TABLE_NAME, null, contentValues); + return true; + } + + public int count() { + SQLiteDatabase db = getReadableDatabase(); + Cursor cursor = db.rawQuery("select COUNT(*) from " + TEST_TABLE_NAME, null); + if (cursor != null && cursor.getCount() > 0) { + cursor.moveToFirst(); + return cursor.getInt(0); + } else { + return 0; + } + } + + private static class CustomDatabasePathContext extends ContextWrapper { + + public CustomDatabasePathContext(Context base) { + super(base); + } + + @Override + public File getDatabasePath(String name) { + File databaseDir = new File(String.format("%s/%s", getFilesDir(), ExtTestDBHelper.DIR_NAME)); + databaseDir.mkdirs(); + File databaseFile = new File(String.format("%s/%s/%s", getFilesDir(), ExtTestDBHelper.DIR_NAME, name)); + return databaseFile; + } + + @Override + public SQLiteDatabase openOrCreateDatabase(String name, int mode, SQLiteDatabase.CursorFactory factory) { + return SQLiteDatabase.openOrCreateDatabase(getDatabasePath(name), null); + } + + @Override + public SQLiteDatabase openOrCreateDatabase(String name, int mode, SQLiteDatabase.CursorFactory factory, DatabaseErrorHandler errorHandler) { + return SQLiteDatabase.openOrCreateDatabase(getDatabasePath(name), null); + } + } +} diff --git a/app/src/main/java/com/sample/database/PersonDBHelper.java b/sample-app-encrypt/src/main/java/com/sample/encrypt/database/PersonDBHelper.java similarity index 99% rename from app/src/main/java/com/sample/database/PersonDBHelper.java rename to sample-app-encrypt/src/main/java/com/sample/encrypt/database/PersonDBHelper.java index 7af93ff..bb95c46 100644 --- a/app/src/main/java/com/sample/database/PersonDBHelper.java +++ b/sample-app-encrypt/src/main/java/com/sample/encrypt/database/PersonDBHelper.java @@ -17,7 +17,7 @@ * */ -package com.sample.database; +package com.sample.encrypt.database; import android.content.ContentValues; import android.content.Context; diff --git a/sample-app-encrypt/src/main/java/com/sample/encrypt/database/room/AppDatabase.java b/sample-app-encrypt/src/main/java/com/sample/encrypt/database/room/AppDatabase.java new file mode 100644 index 0000000..63aa947 --- /dev/null +++ b/sample-app-encrypt/src/main/java/com/sample/encrypt/database/room/AppDatabase.java @@ -0,0 +1,14 @@ +package com.sample.encrypt.database.room; + +import android.arch.persistence.room.Database; +import android.arch.persistence.room.RoomDatabase; + +/** + * Created by anandgaurav on 12/02/18. + */ +@Database(entities = {User.class}, version = 1, exportSchema = false) +public abstract class AppDatabase extends RoomDatabase { + + public abstract UserDao userDao(); + +} diff --git a/sample-app-encrypt/src/main/java/com/sample/encrypt/database/room/User.java b/sample-app-encrypt/src/main/java/com/sample/encrypt/database/room/User.java new file mode 100644 index 0000000..f5fdf32 --- /dev/null +++ b/sample-app-encrypt/src/main/java/com/sample/encrypt/database/room/User.java @@ -0,0 +1,17 @@ +package com.sample.encrypt.database.room; + +import android.arch.persistence.room.Entity; +import android.arch.persistence.room.PrimaryKey; + +/** + * Created by anandgaurav on 12/02/18. + */ +@Entity(tableName = "users") +public class User { + + @PrimaryKey + public Long id; + + public String name; + +} diff --git a/sample-app-encrypt/src/main/java/com/sample/encrypt/database/room/UserDBHelper.java b/sample-app-encrypt/src/main/java/com/sample/encrypt/database/room/UserDBHelper.java new file mode 100644 index 0000000..7304480 --- /dev/null +++ b/sample-app-encrypt/src/main/java/com/sample/encrypt/database/room/UserDBHelper.java @@ -0,0 +1,46 @@ +package com.sample.encrypt.database.room; + +import android.arch.persistence.db.SupportSQLiteDatabase; +import android.arch.persistence.room.Room; +import android.content.Context; + +import java.util.List; + +/** + * Created by anandgaurav on 12/02/18. + */ + +public class UserDBHelper { + + private final AppDatabase appDatabase; + private final AppDatabase inMemoryAppDatabase; + + public UserDBHelper(Context context) { + appDatabase = Room.databaseBuilder(context, AppDatabase.class, "User.db") + .allowMainThreadQueries() + .build(); + inMemoryAppDatabase = Room.inMemoryDatabaseBuilder(context, AppDatabase.class) + .allowMainThreadQueries() + .build(); + } + + public void insertUser(List userList) { + appDatabase.userDao().insertAll(userList); + } + + public void insertUserInMemory(List userList) { + inMemoryAppDatabase.userDao().insertAll(userList); + } + + public int count() { + return appDatabase.userDao().loadAll().size(); + } + + public int countInMemory() { + return inMemoryAppDatabase.userDao().loadAll().size(); + } + + public SupportSQLiteDatabase getInMemoryDatabase() { + return inMemoryAppDatabase.getOpenHelper().getWritableDatabase(); + } +} diff --git a/sample-app-encrypt/src/main/java/com/sample/encrypt/database/room/UserDao.java b/sample-app-encrypt/src/main/java/com/sample/encrypt/database/room/UserDao.java new file mode 100644 index 0000000..e93f507 --- /dev/null +++ b/sample-app-encrypt/src/main/java/com/sample/encrypt/database/room/UserDao.java @@ -0,0 +1,33 @@ +package com.sample.encrypt.database.room; + +import android.arch.persistence.room.Dao; +import android.arch.persistence.room.Delete; +import android.arch.persistence.room.Insert; +import android.arch.persistence.room.OnConflictStrategy; +import android.arch.persistence.room.Query; + +import java.util.List; + +/** + * Created by anandgaurav on 12/02/18. + */ + +@Dao +public interface UserDao { + + @Query("SELECT * FROM users") + List loadAll(); + + @Query("SELECT * FROM users WHERE id IN (:userIds)") + List loadAllByIds(List userIds); + + @Insert(onConflict = OnConflictStrategy.REPLACE) + void insert(User user); + + @Insert(onConflict = OnConflictStrategy.REPLACE) + void insertAll(List users); + + @Delete + void delete(User user); + +} diff --git a/sample-app-encrypt/src/main/java/com/sample/encrypt/utils/Utils.java b/sample-app-encrypt/src/main/java/com/sample/encrypt/utils/Utils.java new file mode 100644 index 0000000..f6aa926 --- /dev/null +++ b/sample-app-encrypt/src/main/java/com/sample/encrypt/utils/Utils.java @@ -0,0 +1,91 @@ +/* + * + * * Copyright (C) 2019 Amit Shekhar + * * Copyright (C) 2011 Android Open Source Project + * * + * * Licensed under the Apache License, Version 2.0 (the "License"); + * * you may not use this file except in compliance with the License. + * * You may obtain a copy of the License at + * * + * * http://www.apache.org/licenses/LICENSE-2.0 + * * + * * Unless required by applicable law or agreed to in writing, software + * * distributed under the License is distributed on an "AS IS" BASIS, + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * See the License for the specific language governing permissions and + * * limitations under the License. + * + */ + +package com.sample.encrypt.utils; + +import android.arch.persistence.db.SupportSQLiteDatabase; +import android.content.Context; +import android.util.Pair; +import android.widget.Toast; + +import com.sample.encrypt.BuildConfig; +import com.sample.encrypt.database.ExtTestDBHelper; + +import java.io.File; +import java.lang.reflect.Method; +import java.util.HashMap; + +/** + * Created by amitshekhar on 07/02/17. + */ + +public class Utils { + + private Utils() { + // This class is not publicly instantiable + } + + public static void showDebugDBAddressLogToast(Context context) { + if (BuildConfig.DEBUG) { + try { + Class debugDB = Class.forName("com.amitshekhar.DebugDB"); + Method getAddressLog = debugDB.getMethod("getAddressLog"); + Object value = getAddressLog.invoke(null); + Toast.makeText(context, (String) value, Toast.LENGTH_LONG).show(); + } catch (Exception ignore) { + + } + } + } + + public static void setCustomDatabaseFiles(Context context) { + if (BuildConfig.DEBUG) { + try { + Class debugDB = Class.forName("com.amitshekhar.DebugDB"); + Class[] argTypes = new Class[]{HashMap.class}; + Method setCustomDatabaseFiles = debugDB.getMethod("setCustomDatabaseFiles", argTypes); + HashMap> customDatabaseFiles = new HashMap<>(); + // set your custom database files + customDatabaseFiles.put(ExtTestDBHelper.DATABASE_NAME, + new Pair<>(new File(context.getFilesDir() + "/" + ExtTestDBHelper.DIR_NAME + + "/" + ExtTestDBHelper.DATABASE_NAME), "")); + setCustomDatabaseFiles.invoke(null, customDatabaseFiles); + } catch (Exception ignore) { + + } + } + } + + public static void setInMemoryRoomDatabases(SupportSQLiteDatabase... database) { + if (BuildConfig.DEBUG) { + try { + Class debugDB = Class.forName("com.amitshekhar.DebugDB"); + Class[] argTypes = new Class[]{HashMap.class}; + HashMap inMemoryDatabases = new HashMap<>(); + // set your inMemory databases + inMemoryDatabases.put("InMemoryOne.db", database[0]); + Method setRoomInMemoryDatabase = debugDB.getMethod("setInMemoryRoomDatabases", argTypes); + setRoomInMemoryDatabase.invoke(null, inMemoryDatabases); + } catch (Exception ignore) { + + } + } + } + +} diff --git a/sample-app-encrypt/src/main/res/drawable-v24/ic_launcher_foreground.xml b/sample-app-encrypt/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..1f6bb29 --- /dev/null +++ b/sample-app-encrypt/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + diff --git a/sample-app-encrypt/src/main/res/drawable/ic_launcher_background.xml b/sample-app-encrypt/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..0d025f9 --- /dev/null +++ b/sample-app-encrypt/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sample-app-encrypt/src/main/res/layout/activity_main.xml b/sample-app-encrypt/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..b5d361c --- /dev/null +++ b/sample-app-encrypt/src/main/res/layout/activity_main.xml @@ -0,0 +1,39 @@ + + + + +