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