0% found this document useful (0 votes)
3 views

8.1 Room Data Access Object (Short Note) PDF

Uploaded by

Vignesh R
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

8.1 Room Data Access Object (Short Note) PDF

Uploaded by

Vignesh R
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

We need to create Data Access Object Interfaces(DAOs) to

communicate with the database. Each database table should have a


corresponding DAO. These interfaces should be annotated with @Dao
annotation.

To insert data we use @Insert annotation. You can choose any name as
the method name. But the parameter of the method definition should
be an Instance of the corresponding entity class(Entity class which
represents the database table). The parameter can be an array or a
collection of objects too.

If the @Insert method receives only 1 parameter, it can return a long,


which is the new row Id for the inserted item. If the parameter is an
array or a collection, it should return long[] or List<Long> instead.
To update data we use @Update annotation. Here also you can choose
any name as the method name. But the parameter of the method
definition should be an Instance , array of instances or a collection of
instances of the corresponding entity class(Entity class which
represents the database table).
To delete data we use @Delete annotation. Here also you can choose
any name as the method name. But the parameter of the method
definition should be an Instance , array of instances or a collection of
instances the corresponding entity class(Entity class which represents
the database table).

Not like inserting, updating or deleting we need to write some SQL for
querying data.

Thank you for reading.


If you have any question please ask from me (using Q & A or
Messages).I am always happy to support you.
Happy Learning……
Anushka Madusanka

You might also like