Android Debug Database: A Library for Debugging Android Databases and Shared Preferences
Android comes with a powerful built-in database called SQLite, but it doesn't come with the best set of debugging tools. When it comes to debugging databases in an android application, it is very difficult to see what’s happening inside the database. The same is true with Shared Preferences. In fact, unless you have a rooted device, you can't even get the SQLite tables off your device without jumping through some hoops.
Android Debug Database
Android Debug Database is a powerful library for debugging SQLite databases and Shared Preferences in Android applications. It allows you to view databases and shared preferences directly in your browser in a very simple way.
By using the Android Debug Database we can do the following:
- See all the databases.
- See all the data in the shared preferences used in your application.
- Run any sql query on the given database to update and delete your data.
- Directly edit the database values.
- Directly edit shared preferences.
- Delete database rows and shared preferences.
- Search in your data.
- Sort data.
- Download database.
Android Debug Database Library in your application
Let’s take a look how we can implement it into our Android applications and debug the SQLite databases and shared preferences.
Complete source code for the examples used in this tutorial is available on github.
Complete source code for the examples used in this tutorial is available on github.
Creating New Project
We’ll start by creating new project in Android Studio and do the basic setup required.Create a new project in Android Studio from File > New Project and fill the project details.
Update Build Configuration
Open build.gradle located under app module and add android debug database dependency.
Create SQLite Database Handler Class
Create a new class in your project src directory and name it as DatabaseHandler.java ( Right Click on src/package > New > Class)
Now extend your DatabaseHandler.java class from SQLiteOpenHelper.
Insert Records
Update MainAcitvity.java file to create the instance of DatabaseHandler.java class and add some rows.
Store Data Using Shared Preferences
Another way of storing data of an application is called Shared Preferences. Shared Preferences allow you to save and retrieve data in the form of key,value pair.
Create a Shared Preference instance and store some values.
Debugging Databases and Shared Preferences
Now we can debug the database and shared preference used in the app with the help of a web interface.
To do that do the following steps:
- Your Android phone and laptop should be connected to the same Network.
- If you are using it over usb, run adb forward tcp:8080 tcp:8080
Start the application, you will see in the logcat an entry like follows :
If you want use different port other than 8080. In the app build.gradle file under buildTypes do the following change :
Thanks for sharing Information to us. If someone wants to know about,I think this is the right place for you!
ReplyDeleteMobile App Development in Coimbatore
Mobile app development company in atlanta
3D Animation Company
Very attractive post and I learn more different tips from your blog. I am waiting for your next posts, keep it up.
ReplyDeleteOracle Training in Chennai
Oracle Training
Social Media Marketing Courses in Chennai
Tableau Training in Chennai
Primavera Training in Chennai
Unix Training in Chennai
Oracle DBA Training in Chennai
Power BI Training in Chennai
Oracle Training in Velachery
Thanks for sharing an informative blog keep rocking bring more details.I like the helpful info you provide in your articles. I’ll bookmark your weblog and check again here regularly. I am quite sure I will learn much new stuff right here! Good luck for the next!
ReplyDeleteweb designer course in chennai
web design development training in chennai
web designing course with placement in chennai
web design and programming courses in chennai
web design and development training in chennai
web designing courses in chennai
web designing training and placement in chennai
Thank you for sharing this! What you have shared is very helpful and informative. Would love to see more updates from you.
ReplyDeleteMelbourne Web Designer