How to check if data is inserted in Room Database

An option you may consider, if you have not access permission issues, is to navigate directly into your sqlite instance of the device and query the tables directly there.

If you use the emulator intehgrated with Android Studio or a rooted phone you can do the following:

adb root
adb remount
cd data/data/path/of/your/application/database
sqlite3 mydb.db

Then you can query your tables


You can use Stetho to see your DB and Shared pref file in chrome dev tool

http://facebook.github.io/stetho/

EDIT: AS has a built-in DB tool now


The problem was in the thread. Room doesn't allow you to run database queries in main thread. The call to insert method was inside of a try-catch block, and I was ignoring the exception. I fixed it, and here's how it reads right now.

doAsync {
                        val addedID = appContext.db.rallyDAO().addVehicleListItem(vehicle)
                        Logger.d("vehicle_lsit_item","Inserted ID $addedID")
        }

Also, I reviewed the documentation, the insert method may return a Long (or List of Long in case of List passed to insert). I also changed the signature of insert, and here is the modified code

@Insert(onConflict = OnConflictStrategy.REPLACE)
fun addVehicleListItem(vehicleListItem:VehicleListItem):Long

P.S. I am using anko for doAsync