View the app's datasheet without root

Source: Internet
Author: User

Always view the database of SQLite requires root to view, but the company's many test machine root up more trouble ~ ~ ~

Just recently the project was on the line, slightly idle,

So decided to write a library project to facilitate debugging code later

The key code is as follows

First, view the current app's database

Context.databaselist ()
Where the Databaselist method is defined as a method in the Contextwrapper class
@Override

    Public string[] Databaselist () {        return mbase.databaselist ();    }

Second, view the data table in the library

Sqlitedatabase db = Dbhelper.getwritabledatabase (); Cursor C = db.rawquery ("Select name from Sqlite_master WHERE type= ' table '", null), if (C.movetofirst ()) {while (!c.isafterl AST ()) {Tables.add (c.getstring (0));//datasheet C.movetonext ();}}

Iii. viewing data in a data table

DBHelper db = new DBHelper (GetContext (), databaseName); Cursor C = db.getwritabledatabase (). query (tableName, NULL, NULL, NULL, NULL, NULL, NULL); string[] ColumnNames = C.getcolumnnames (); arraylist<string> datas = new arraylist<string> (); StringBuilder sb = new StringBuilder (), if (C.movetofirst ()) {while (!c.isafterlast ()) {sb.setlength (0), for (String columnname:columnnames) {int columnindex = C.getcolumnindex (columnName); String Colvalue = c.getstring (columnindex), Sb.append (ColumnName). Append (":"). Append (Colvalue). Append ("\ n");} Datas.add (Sb.tostring ()); LOG.D ("Table_" + TableName, sb.tostring ()); C.movetonext ();}}

The above code in addition to Databaselist () This method looked for a long time, the other relatively simple point


which Viewing the app table data is just starting with the root Explorer to make a browse data control. But I think it's a bit more complicated, but it's not yet realized.

Links to projects in this

Https://github.com/droidcoffee/yolanda/tree/master/yolanda_Android


Note the use of the project as a library project to introduce

Also modify the main project Project.Properties file to add the following configuration.

Manifestmerger.enabled=true
This enables the activity configured in the Androidmanifest.xml in the library to take effect.

That is, it is not reconfigured in the main project without copy.


You can add group 299306868 if you have problems.

View the app's datasheet without root

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.