android - How to check if data is inserted in Room Database -
i using room database new architecture components in project. adding data through dao, when trying retrieve not getting it. can please suggest me how check whether insert successful or not? below codes understand problem.
adding database, checked debugger, statement executed successfully.
appcontext.db.rallydao().addvehiclelistitem(vehicle)
getting null database on statement after insert.
val v = appcontext.db.rallydao().getvehiclelistitem(it.vehicleid)
roomdatabase
@database(entities = arrayof(rally::class, route::class, checkpoints::class, vehicles::class, vehiclelistitem::class), version = 1) abstract class tsdroom: roomdatabase() { public abstract fun rallydao():rallydao }
inside dao
@insert(onconflict = onconflictstrategy.replace) fun addvehiclelistitem(vehiclelistitem:vehiclelistitem) @query("select * vehicles_submitted vehicle_id :vehicleid") fun getvehiclelistitem(vehicleid:string):vehiclelistitem
vehiclelistitem entity
@entity(tablename = "vehicles_submitted", foreignkeys = arrayof(foreignkey(entity = rally::class, parentcolumns = arrayof("rally_id"), childcolumns = arrayof("rally_id")))) class vehiclelistitem { @primarykey @columninfo(name = "vehicle_id") @serializedname("vehicle_id") var vehicleid : string = "" @columninfo(name = "driver_id") @serializedname("driver_id") var driverid : string = "" @columninfo(name = "vehicle_name") @serializedname("vehicle_name") var vehiclename : string = "" @columninfo(name = "driver_name") @serializedname("driver_name") var drivername : string = "" @columninfo(name = "driver_email") @serializedname("driver_email") var driveremail : string = "" @columninfo(name = "rally_id") @serializedname("rally_id") var rallyid: string = "" @columninfo(name = "is_passed") @serializedname("is_passed") var ispassed = false @columninfo(name = "passing_time") @serializedname("passing_time") var passingtime:string="" }
an option may consider, if have not access permission issues, navigate directly sqlite instance of device , query tables directly there.
if use emulator intehgrated android studio or rooted phone can following:
adb root adb remount cd data/data/path/of/your/application/database sqlite3 mydb.db
then can query tables
Comments
Post a Comment