Debug the database on Android Studio (SQLite)

Source: Internet
Author: User
Tags sqlite database

Transferred from: http://c.colabug.com/thread-1781696-1-1.html

Prior to the Eclipse era, debugging SQLite was to export the database files to a computer and then open the view with the software. Now that we are using Android Studio, is there a more convenient way?
Sqlscout

installation

Sqlscout is a plugin for Android Studio, by clicking on:
Setting-> plugings-> Browse repositories
Search Sqlscout installation.
If the download is not moving, you can download it here, then click Install Plugin from disk to import.
Loading

After successful installation restart Android Studio, you will find the right side bar appears SQLite Exporer, expand and click "+" will appear three options:
Let's say it from the bottom up.
Local SQLite Database

If the database you are debugging is already exported to your computer, select this option to load.
Android (Download Database locally)

Normally, the database that we want to debug is on the phone, can use this function to extract the database. Select the device you want to debug, the project package name, and the database name.
Android (Live Device Connection)

The disadvantages of the above two methods are obvious and the database cannot be updated in real time.
Live Device Connection is a new feature of Sqlscout 2.0, and the difference is that it can manage and update the database in real time.
Before you use it, you need to add it in Project Build.gradle:
    1. allprojects {
    2. repositories {
    3. Jcenter ()
    4. Maven {
    5. URL ' http://www.idescout.com/maven/repo/'
    6. }
    7. }
    8. }
Copy CodeInside the module's build.gradle, add:
    1. Compile ' com.idescout.sql:sqlscout-server:2.0 '
Copy CodeAdd a line of code to the OnCreate method of the activated Activity:
    1. Sqlscoutserver.create (this, getpackagename ());
Copy Code Debug

The entire interface is as follows:
Each of them is:
           

    • Database list: The list of databases to debug, expand the table in the display database, and right-click to open the SQL editor.
    • SQL Editor: A place to enter SQL statements that supports auto-completion and code highlighting.
    • Data console: Displays the data of the query in an Excel-like format, or you can edit the data here.
    • Data diagrams: Relationships that are used to show tables and fields.
is not very useful, is simply an artifact Ah! But it's a charge for something so good.
Poor cock silk can't afford to do? Then look down.
Android Debug Database

This is an open source project (free), the project address is here.
First, add the Build.gradle inside the module:
    1. Debugcompile ' com.amitshekhar.android:debug-db:1.0.0 '
Copy CodeLet the phone and the computer in a LAN, when the project ran up, in the logcat inside will print out such a line:
    1. D/debugdb:open http://XXX.XXX.X.XXX:8080 in your browser
Copy CodeCopy the address to the browser and you will see an interface like this:
It is easy to understand that several of the columns are:
           

    • Query: Where to write SQL statements
    • Databases: Database
    • Tables: Tables in the database
    • Data: tables, support editing, searching
It's that simple, and it's a complete one.

By Rare earth Nuggets https://juejin.im/post/58e0d781a0bb9f0069ec08d3

Debugging the Database (SQLite) on Android Studio (go)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.