Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# These are supported funding model platforms

github: [amitshekhariitbhu]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
18 changes: 17 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)*
----------------------------

Expand Down Expand Up @@ -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)*
Expand Down
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,31 @@

### All these features work without rooting your device -> No need of rooted device

### Check out another awesome library for fast and simple networking in Android
### Check out our other Open Source Projects

* [Fast Android Networking Library](https://github.com/amitshekhariitbhu/Fast-Android-Networking)
* [Learn to build a ride-sharing Android app like Uber, Lyft](https://github.com/MindorksOpenSource/ridesharing-uber-lyft-app)
* [Kotlin-Coroutines-Android-Examples](https://github.com/MindorksOpenSource/Kotlin-Coroutines-Android-Examples)

### Using Android Debug Database Library in your application

Add this to your app's build.gradle

```groovy
debugImplementation 'com.amitshekhar.android:debug-db:1.0.5'
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'
```
And to provide the password for the DB, you should add this in the Gradle:
DB_PASSWORD_{VARIABLE}, if for example, PERSON is the database name: DB_PASSWORD_PERSON
```groovy
debug {
resValue("string", "DB_PASSWORD_PERSON", "password")
}
```

Use `debugImplementation` so that it will only compile in your debug build and not in your release build.
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Expand Down
3 changes: 2 additions & 1 deletion debug-db-base/debug-db-base-upload.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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.5'
version = '1.0.6'

install {
repositories.mavenInstaller {
Expand Down Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<TableDataResponse.TableInfo> 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 {
Expand Down
2 changes: 1 addition & 1 deletion debug-db-encrypt/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ 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'
Expand Down
3 changes: 2 additions & 1 deletion debug-db-encrypt/debug-db-encrypt-upload.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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.5'
version = '1.0.6'

install {
repositories.mavenInstaller {
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion debug-db/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ 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'
Expand Down
3 changes: 2 additions & 1 deletion debug-db/debug-db-upload.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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.5'
version = '1.0.6'

install {
repositories.mavenInstaller {
Expand Down Expand Up @@ -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
}
Expand Down
19 changes: 9 additions & 10 deletions sample-app-encrypt/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,33 @@ 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-optimize.txt'), 'proguard-rules.pro'
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

debugImplementation project(':debug-db-encrypt')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
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'
Expand Down
136 changes: 135 additions & 1 deletion sample-app-encrypt/src/main/java/com/sample/encrypt/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,147 @@
/*
*
* * 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;

import android.support.v7.app.AppCompatActivity;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

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;
import java.util.List;
import java.util.Set;

public class MainActivity extends AppCompatActivity {

@SuppressLint("CommitPrefEdits")
@Override
protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

Set<String> stringSet = new HashSet<>();
stringSet.add("SetOne");
stringSet.add("SetTwo");
stringSet.add("SetThree");

SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());

SharedPreferences prefsOne = getSharedPreferences("countPrefOne", Context.MODE_PRIVATE);
SharedPreferences prefsTwo = getSharedPreferences("countPrefTwo", Context.MODE_PRIVATE);

sharedPreferences.edit().putString("testOne", "one").commit();
sharedPreferences.edit().putInt("testTwo", 2).commit();
sharedPreferences.edit().putLong("testThree", 100000L).commit();
sharedPreferences.edit().putFloat("testFour", 3.01F).commit();
sharedPreferences.edit().putBoolean("testFive", true).commit();
sharedPreferences.edit().putStringSet("testSix", stringSet).commit();

prefsOne.edit().putString("testOneNew", "one").commit();

prefsTwo.edit().putString("testTwoNew", "two").commit();

ContactDBHelper contactDBHelper = new ContactDBHelper(getApplicationContext());
if (contactDBHelper.count() == 0) {
for (int i = 0; i < 100; i++) {
String name = "name_" + i;
String phone = "phone_" + i;
String email = "email_" + i;
String street = "street_" + i;
String place = "place_" + i;
contactDBHelper.insertContact(name, phone, email, street, place);
}
}

CarDBHelper carDBHelper = new CarDBHelper(getApplicationContext());
if (carDBHelper.count() == 0) {
for (int i = 0; i < 50; i++) {
String name = "name_" + i;
String color = "RED";
float mileage = i + 10.45f;
carDBHelper.insertCar(name, color, mileage);
}
}

ExtTestDBHelper extTestDBHelper = new ExtTestDBHelper(getApplicationContext());
if (extTestDBHelper.count() == 0) {
for (int i = 0; i < 20; i++) {
String value = "value_" + i;
extTestDBHelper.insertTest(value);
}
}

// Create Person encrypted database
PersonDBHelper personDBHelper = new PersonDBHelper(getApplicationContext());
if (personDBHelper.count() == 0) {
for (int i = 0; i < 100; i++) {
String firstName = PersonDBHelper.PERSON_COLUMN_FIRST_NAME + "_" + i;
String lastName = PersonDBHelper.PERSON_COLUMN_LAST_NAME + "_" + i;
String address = PersonDBHelper.PERSON_COLUMN_ADDRESS + "_" + i;
personDBHelper.insertPerson(firstName, lastName, address);
}
}

// Room database
UserDBHelper userDBHelper = new UserDBHelper(getApplicationContext());
if (userDBHelper.count() == 0) {
List<User> userList = new ArrayList<>();
for (int i = 0; i < 20; i++) {
User user = new User();
user.id = (long) (i + 1);
user.name = "user_" + i;
userList.add(user);
}
userDBHelper.insertUser(userList);
}

// Room inMemory database
if (userDBHelper.countInMemory() == 0) {
List<User> userList = new ArrayList<>();
for (int i = 0; i < 20; i++) {
User user = new User();
user.id = (long) (i + 1);
user.name = "in_memory_user_" + i;
userList.add(user);
}
userDBHelper.insertUserInMemory(userList);
}

Utils.setCustomDatabaseFiles(getApplicationContext());
Utils.setInMemoryRoomDatabases(userDBHelper.getInMemoryDatabase());
}

public void showDebugDbAddress(View view) {
Utils.showDebugDBAddressLogToast(getApplicationContext());
}
}
Loading