I'm developing an application with ionic
on IntelliJ IDEA. I've created a new project PhoneGap/Cordova App
, also I deploy the .apk
perfectly on the device of android emulator. But I don't know how to access to Database of the emulator, to see if I'm inserting my data correctly. How to connect to the emulator to access the Database?
-
https://github.com/sanathp/DatabaseManager_For_Android – subhash Sep 27 '15 at 05:11
4 Answers
Go to DDMS -> file explorer -> data -> data -> your package name -> databases -> here your database file.
Pull that database & open it in sqlite browser or mozilla sqlite plugin.

- 10,457
- 4
- 35
- 55
Usually database is part of your application and you ship it as asset folder. When you deploy the application, a folder of your application package name is created in data folder, where you can see your database file as well. when application modifies the database, and you want to see the current state, copy the database into local folder and open it using Firefox browser, you can see the table and its data.

- 604
- 1
- 4
- 11

- 5,541
- 1
- 20
- 17
-
But I need to see and manage the database from the device itself, not locally, because the changes will not be updated. – in3pi2 Sep 30 '15 at 22:27
The only way to gain access to an application's database file is to have a rooted device. The android system intentionally protects those files from being accessed.
There are some posts on how to go about rooting an android emulator on Stack Overflow, like this one: How to get root access on Android emulator?
If you don't want to do that, you can use a utility class to export your sqlite database to your local filesystem and then view it with a sqlite application on said device or your computer.
public String backupDatabase(Context context) throws IOException {
File dbFile = context.getDatabasePath("YOUR_DATABASE_NAME.db");
FileInputStream fis = new FileInputStream(dbFile);
String outFileName = String.format("%s/%s.db", Environment.getExternalStorageDirectory(), "DATABASE_FILE_NAME");
// Open the empty db as the output stream
OutputStream output = new FileOutputStream(outFileName);
byte[] buffer = new byte[1024];
int length;
while ((length = fis.read(buffer)) > 0) {
output.write(buffer, 0, length);
}
// Close the streams
output.flush();
output.close();
fis.close();
return outFileName;
}
I found the best tool to view and manage the databases from the device itself (SQLite Editor https://goo.gl/ALzc8A). Very useful!!
PD: I installed that app on Genymotion, which is much better than the default SDK emulator.

- 877
- 1
- 11
- 22