Saving Data on Android



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

Question
 table using the 
question
 object passed as a parameter and 
the second method is going to create a new record in your 
Answer
 table.
You might have also noticed the 
onConflict
 parameter in the 
@Insert
 annotation. 
It allows you to define an 
OnConflictStrategy
, which will be used to specify what 
happens in case there is a conflict when creating a new entry. There are several 
options:

ABORT
 this is the default option and instructs Room to abort the transaction, 
return an error and roll back any changes made by the current SQL statement.

FAIL
 makes the transaction fail and return an error.

IGNORE
 makes the transaction ignore the conflict and continue as expected.

REPLACE
 replaces the old data with the new values and continues the transaction.

ROLLBACK
 aborts the current transaction and rolls back any changes made.
That is all you need to create a DAO to insert new questions and answers into your 
Database. Now, create the methods to delete questions.
Add the following method:
@Query("DELETE FROM questions")
 
fun
 
clearQuestions
()
Saving Data on Android
Chapter 8: The DAO Pattern
raywenderlich.com
134


The above code uses the 
@Query
 annotation to execute a 

Download 19,28 Mb.

Do'stlaringiz bilan baham:
1   ...   144   145   146   147   148   149   150   151   ...   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