If the cell phone does not have root, the database file is unable to see, inconvenient debugging.
The best way is to write the database into the SD card.
There are two places to modify:
1. In your helper class, database_name the name of the database file from the original filename and modifies it to the form of a path.
Before modification: database_name = "DEMO.DB"
public class Mydbhelper extends Sqliteopenhelper {public
static final int version = 1;//database version number public
static fin Al String database_name = "DEMO.DB"; Database name public
static FINAL String table_name = "mytag";//datasheet name, a database can contain more than one datasheet, similar to the Sheet1,sheet2 in Excel
// Mydbhelper's constructor, we are concerned with the name database_name and version versions public
Mydbhelper {
Super database_name, NULL, VERSION);
Modified: database_name = "/MNT/SDCARD/DEMO.DB"
public class Mydbhelper extends Sqliteopenhelper {public
static final int version = 1;//database version number public
static fin Al String database_name = "/MNT/SDCARD/DEMO.DB"; Database name public
static FINAL String table_name = "mytag";//datasheet name, a database can contain more than one datasheet, similar to the Sheet1,sheet2 in Excel
// Mydbhelper's constructor, we are concerned with the name database_name and version versions public
Mydbhelper {
Super database_name, NULL, VERSION);
Because if just a separate file name, the last created database file is stored in the phone's internal memory card (not running RAM, also not SD card) of the/data/data/package name/databases directory, and no root mobile phone, this/data root folder is not going to go, It can't be opened with the ADB shell.
2. Finally, do not forget to modify the permissions!
Android phone is a strict security control, the SD card belongs to the external storage, access to the above files need to add permissions.
Add two SD card read and Write permissions to the Androidmanifest.xml:
<uses-permission android:name= "Android.permission.WRITE_EXTERNAL_STORAGE"/>
If you do not add permissions, the program terminates abnormally.
The above mentioned is for the Android database SQLite write SD card method, hope to help everyone!