Saving Data on Android


get the list of all the questions



Download 19,28 Mb.
Pdf ko'rish
bet147/292
Sana24.01.2022
Hajmi19,28 Mb.
#407089
1   ...   143   144   145   146   147   148   149   150   ...   292
Bog'liq
Bailey J., Dominguez A., Djermanovic D. - Saving Data on Android (1st Edition) - 2019

get the list of all the questions
 currently stored in your 
database.
• You will also need to be able to 
create new questions
 when your app is created.
• Finally, you will also have to 
delete questions
 at some point.
With the above in mind, create a DAO in your project that perform 
CREATE

READ

and 
DELETE
 queries in your database. You will see how easy it is to create DAOs in 
Room.
Saving Data on Android
Chapter 8: The DAO Pattern
raywenderlich.com
133


Create a new interface under the 
db
 package and name it 
QuizDao
. To turn your new 
interface into a DAO, simply add the 
@Dao
 annotation like below:
@Dao
 
interface
 
QuizDao
 { 
}
Now, add the following code to the interface:
@Insert(onConflict = OnConflictStrategy.REPLACE)
 
fun
 
insert
(question: Question)
 
 
@Insert(onConflict = OnConflictStrategy.REPLACE)
 
fun
 
insert
(answer: Answer)
The 
@Insert
 annotation is a shortcut that allows you to automatically create an 
INSERT INTO
 query, that creates a new record in the appropriate table, with the 
object passed as a parameter. In this case, the first method is going to create a new 
record in your 

Download 19,28 Mb.

Do'stlaringiz bilan baham:
1   ...   143   144   145   146   147   148   149   150   ...   292




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish