Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

View contents of database created with Room Persistence Library

Is there any easier way to see the contents of database created with Room Persistence Library in Android Studio?

like image 421
SpiralDev Avatar asked Jun 08 '17 07:06

SpiralDev


People also ask

How do you check data in a room database?

Database Inspector Officially Support in Android Studio You have to choose your connected device, then need to choose package name that you want to inspect for database. In the left side, show the available tables and need to double click to see table details, and it will be show in the right side.

Which of the following is provided by room persistence library?

The Room persistence library provides an abstraction layer over SQLite to allow fluent database access while harnessing the full power of SQLite. In particular, Room provides the following benefits: Compile-time verification of SQL queries.

Is room database persistent?

Room is a persistence library that's part of Android Jetpack. Room is an abstraction layer on top of a SQLite database. SQLite uses a specialized language (SQL) to perform database operations. Instead of using SQLite directly, Room simplifies the chores of setting up, configuring, and interacting with the database.

Where is the database stored in Android Studio?

Open Device File Explorer via View > Tool Windows > Device File Explorer. Go to data > data > PACKAGE_NAME > database , where PACKAGE_NAME is the name of your package (it is com. Movie in the example above) Right click on the database and select Save As... . Save it anywhere you want on your PC.


2 Answers

In older Android Studio versions:

Emulator -> Android Studio -> Device File Explorer -> /data/data/{$packageId}/databases/ -> Save As -> https://sqlitebrowser.org/ 

In later Android Studio versions (3.5+):

View -> Tool Windows -> Device File Explorer -> /data/data/{$packageId}/databases/ -> Save As -> https://sqlitebrowser.org/ 
like image 142
kreker Avatar answered Nov 01 '22 23:11

kreker


in android studio 3.1.*

in tool window bar click on "Device File explorer" generally you can find this in bottom right corner of the screenn

open directory in data/data/your-application-package/databases

with new architecture 3 files is created in databases directory

your-database-name your-database-name-shm your-database-name-wal 

you have to export all 3 in the same directory

then open first one file (that is with your-database-name only ) in any sqlite browser.

and now you can see all your data .......

your-database-name-shm your-database-name-wal 

these two extra files are needed to open db file if you will open database file only, than you will not found any table in that file

like image 28
Avinash Jadaun Avatar answered Nov 01 '22 22:11

Avinash Jadaun