Saving Data on Android



Download 19,28 Mb.
Pdf ko'rish
bet140/292
Sana24.01.2022
Hajmi19,28 Mb.
#407089
1   ...   136   137   138   139   140   141   142   143   ...   292
Bog'liq
Bailey J., Dominguez A., Djermanovic D. - Saving Data on Android (1st Edition) - 2019

one-to-
many
 relations: The 
@Relation
 annotation.
@Relation
 is a very handy annotation that automatically retrieves records from 
related entities. You can apply it to a 
List
 or 
Set
  of objects and Room will take care 
of the rest for you. To see the 
@Relation
 in action, create a new class under the 
data 

 model
 package and name it 
QuestionAndAllAnswers
.
Replace everything inside with the following:
class
 
QuestionAndAllAnswers
 { 
    
@Embedded
//1
 
    
var
 question: Question? = 
null
 
 
    
@Relation(parentColumn = "question_id",//2 
              entityColumn = "question_id")
 
    
var
 answers: List = ArrayList()
//3
 
}
Step by step:
1. Since you want to be able to access all the fields in the 
Question
 entity, we are 
using the 
@Embedded
 annotation to retrieve all the properties from that entity. If 
you need a reminder of how annotations like 
@Embedded
 work, take a look at the 

Download 19,28 Mb.

Do'stlaringiz bilan baham:
1   ...   136   137   138   139   140   141   142   143   ...   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