Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - How can I view a sql database created in my app? I'm running it on the Android emulator in Eclipse

I have an Android application that uses the Android database to create tables and store data. I'm currently running this app in the emulator in Eclipse. I have 2 questions:

  1. Where can I find the actual database file (it must be on my computer somewhere right?) that is created when I run my app in the emulator?
  2. Is there an easy way to view what is in my database/tables?

If I could find where the actual database file is (if there is such a thing) on my computer, then perhaps question 2 would be answered as easily as opening that file. But I really have no clue. Any help is appreciated.

like image 588
Tim Avatar asked Mar 23 '12 20:03

Tim


People also ask

How do I view a SQL database?

Using SQL Server Management Studio In Object Explorer, connect to an instance of the SQL Server Database Engine, and then expand that instance. Expand Databases, right-click the database to view, and then click Properties. In the Database Properties dialog box, select a page to view the corresponding information.


2 Answers

Hi

1. In the Eclipse look at the File Explorer tab (near the Console tab). Or look at menu "Window -> Show View -> Other... -> File Explorer". Emulator should be run. In the File Explorer window go to the folder "data/data/[your_package_name]/databases/". There you can find your database. You can export it to the your computer. At the right top corner of the window there is a button "pull a file from device". Select database, click that button and save a database on the computer.

2. Program "sqlite browser" can shows a data in the database. You can download it here. It is easy to use.

like image 120
Taras Feschuk Avatar answered Oct 21 '22 21:10

Taras Feschuk


The database is stored in the following location on the emulator (assuming your app has the package com.example.app and a database named db-name.db):

/data/data/com.example.app/db-name.db

You can access it from the command line as follows:

cmd> adb -e shell
cmd> sqlite3 /data/data/com.example.app/databases/db-name.db
sqlite> select * from table_name;
sqlite> 1|Example Item 1|1|
sqlite> 2|Example Item 2|2|
sqlite>
like image 31
Paul Drummond Avatar answered Oct 21 '22 20:10

Paul Drummond