![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
github.com/amitshekhariitbhu/Android-Debug-Database
Hi, I am Amit Shekhar, Co-Founder @ Outcome School • IIT 2010-14 • I have taught and mentored many developers, and their efforts landed them high-paying tech jobs, helped many tech companies in solving their unique problems, and created many open-source libraries being used by top companies. I am passionate about sharing knowledge through open-source, blogs, and videos.
You can connect with me on:
Add this to your app's build.gradle
debugImplementation 'com.amitshekhar.android:debug-db:1.0.6'
Using the Android Debug Database with encrypted database
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
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.
That’s all, just start the application, you will see in the logcat an entry like follows :
D/DebugDB: Open http://XXX.XXX.X.XXX:8080 in your browser
You can also always get the debug address url from your code by calling the method DebugDB.getAddressLog();
Now open the provided link in your browser.
Important:
adb forward tcp:8080 tcp:8080
Note : If you want use different port other than 8080. In the app build.gradle file under buildTypes do the following change
debug {
resValue("string", "PORT_NUMBER", "8081")
}
You will see something like this :
<img src=https://raw.githubusercontent.com/amitshekhariitbhu/Android-Debug-Database/master/assets/debugdb.png >
adb forward tcp:8080 tcp:8080
and open http://localhost:8080As this library is auto-initialize, if you want to get the address log, add the following method and call (we have to do like this to avoid build error in release build as this library will not be included in the release build) using reflection.
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) {
}
}
}
As this library is auto-initialize, if you want to debug custom database files, add the following method and call
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<String, Pair<File, String>> 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) {
}
}
}
As this library is auto-initialize, if you want to debug inMemory Room databases, add the following method and call
public static void setInMemoryRoomDatabases(SupportSQLiteDatabase... database) {
if (BuildConfig.DEBUG) {
try {
Class<?> debugDB = Class.forName("com.amitshekhar.DebugDB");
Class[] argTypes = new Class[]{HashMap.class};
HashMap<String, SupportSQLiteDatabase> 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) {
}
}
}
You can connect with me on:
Copyright (C) 2024 Amit Shekhar
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.
All pull requests are welcome, make sure to follow the contribution guidelines when you submit pull request.
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.