How to print query in Room
? Not the query written in dao but the query generated by room itself.
Asked
Active
Viewed 3,500 times
5

Phantômaxx
- 37,901
- 21
- 84
- 115

Sujin Shrestha
- 1,203
- 2
- 13
- 23
-
2At this time Room doesn't have any logging policy itself – Reza Bigdeli Apr 23 '18 at 10:03
-
You can log Room's Sqlite statements on emulator, check my answer here: https://stackoverflow.com/a/54963655/1233652 – Alex Lipov Mar 02 '19 at 22:47
1 Answers
5
For every DAO class you add to your project marked with @Dao
Room generate a class that implement your class. Hence for operations like Insert, Update and Delete that you don't provide any query Room will create a query itself. You can see this generated classes in the following file inside your project:
{root project}/app/build/generated/source/apt
, now navigate to the package that contains DAO classes and you will see classes like IssueDao_Impl.java
. Inside this class you will see queries like this:
"INSERT OR REPLACE INTO `Issue`(`id`,`displayOrder`,`pdf`,`date`,`purchasable`,`source_id`,`thumb`,`full`,`mobile`,`width`,`height`,`download_count`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)";
, created with the help of the annotations you did inside your class. Cheers!

Keivan Esbati
- 3,376
- 1
- 22
- 36