How to View Data Saved in Android Database(Sqlite)

How to view data saved in android database(SQLite)?

You can access this folder using the DDMS for your Emulator. you can't access this location on a real device unless you have a rooted device.

You can view Table structure and Data in Eclipse. Here are the steps

  1. Install SqliteManagerPlugin for Eclipse. Jump to step 5 if you already have it.
  2. Download the *.jar file from here
  3. Put the *.jar file into the folder eclipse/dropins/
  4. Restart eclipse
  5. In the top right of eclipse, click the DDMS icon
  6. Select the proper emulator in the left panel
  7. In the File Explorer tab on the main panel, go to /data/data/[YOUR.APP.NAMESPACE]/databases
  8. Underneath the DDMS icon, there should be a new blue icon of a Database light up when you select your database. Click it and you will see a Questoid Sqlite Manager tab open up to view your data.

*Note: If the database doesn't light up, it may be because your database doesn't have a *.db file extension. Be sure your database is called [DATABASE_NAME].db

*Note: if you want to use a DB without .db-Extension:

  1. Download this Questoid SqLiteBrowser: http://www.java2s.com/Code/JarDownload/com.questoid/com.questoid.sqlitebrowser_1.2.0.jar.zip

  2. Unzip and put it into eclipse/dropins (not Plugins)

Check this for more information

View contents of database file in Android Studio

Finally, i found a simplest solution which do not need to open the DDMS.

Actually, the solution is based on what @Distwo mentioned, but it don't have to be that complicated.

First, remember the path of your database file in the device, it should aways the same.
For example mine is:/data/data/com.XXX.module/databases/com.XXX.module.database

Second, execute this command which pulls your database file onto you PC

 adb pull /data/data/com.XXX.module/databases/com.XXX.module.database /Users/somePathOnYourPC/

What you need to do is just copy and store this command, then you can use it again and again.

Third, if you got Permission Denied or something like that, just run adb root before the previous command.

Where is my sqlite database stored in android?

In my rooted phone, it's in : /data/data/<your_app_package_name>/databases/<database_name>

exemple
/data/data/com.my.package/databases/mydb

How to see the data stored in sqlite in android studio using genymotion as emulator

  1. Go to Tools -> DDMS or click the Device Monitor icon next to SDK Manager in Tool bar.

  2. Device Monitor window will open. In File Explorer tab, click data -> data -> your project name. After that your databases file will open. Click pull a file from device icon. Save the file using .db extension.

  3. Open FireFox, Press Alt , Tools -> SQLiteManager.

  4. Follow Database -> connect to Database -> browse your database file and click ok. Your SQLite file will opened now.

SQLite Database storage in /data/data Android

I think you hav to change the DB_NAME variable from "my_database" to "my_database.sqlite"

and u cant see your database on your internal memory... bcoz the database will save only to the system folder...
if u want to check it u might need a rooted android device or you can check using android studio...

check this link... check database if exist in android studio

Android - Where is SQLite Database stored

Open the DDMS perspective Window: (window->open perspective->other->DDMS) It should open in a new tab.

Go to DDMS -> file explorer -> data -> data -> see your package name -> databases -> here your database file. (In the upper right, choose "Pull file" from device.) Export it and open through an Sqlite database connector.

You will see your updated data. Before taking these steps make sure that you have run your application first.

View SQLite database on device in Android Studio

Connect to Sqlite3 via ADB Shell

I haven't found any way to do that in Android Studio, but I access the db with a remote shell instead of pulling the file each time.

Find all info here:
http://developer.android.com/tools/help/adb.html#sqlite

1- Go to your platform-tools folder in a command prompt

2- Enter the command adb devices to get the list of your devices

C:\Android\adt-bundle-windows-x86_64\sdk\platform-tools>adb devices
List of devices attached
emulator-xxxx device

3- Connect a shell to your device:

C:\Android\adt-bundle-windows-x86_64\sdk\platform-tools>adb -s emulator-xxxx shell

4- Navigate to the folder containing your db file:

cd data/data/<your-package-name>/databases/

5- run sqlite3 to connect to your db:

sqlite3 <your-db-name>.db

6- run sqlite3 commands that you like eg:

Select * from table1 where ...;

Note: Find more commands to run below.

SQLite cheatsheet

There are a few steps to see the tables in an SQLite database:

  1. List the tables in your database:

    .tables
  2. List how the table looks:

    .schema tablename
  3. Print the entire table:

    SELECT * FROM tablename;
  4. List all of the available SQLite prompt commands:

    .help

Source : This SO answer..



Related Topics



Leave a reply



Submit