Saving Data on Android


ALTER  query to change your  question



Download 19,28 Mb.
Pdf ko'rish
bet188/292
Sana24.01.2022
Hajmi19,28 Mb.
#407089
1   ...   184   185   186   187   188   189   190   191   ...   292
Bog'liq
Bailey J., Dominguez A., Djermanovic D. - Saving Data on Android (1st Edition) - 2019

ALTER
 query to change your 
question
 table.
Modify 
migrate
 like this:
override
 
fun
 
migrate
(database: SupportSQLiteDatabase)
 { 
  database.execSQL(
"ALTER TABLE question ADD COLUMN difficulty 
INTEGER NOT NULL DEFAULT 0"

}
database.execSQL()
 executes the query passed as a parameter. Here, you're 
executing an 
ALTER TABLE
 query in your 
question
 table that adds a new 
difficulty
 
column that only accepts integers. It has a default value of 0.
Saving Data on Android
Chapter 10: Migrations with Room
raywenderlich.com
178


Now that you've defined your migration, you need to tell Room to execute it before 
building your database.
Open 
QuizDatabase.kt
 and add the following companion object to the top of your 
class:
companion
 
object
 { 
  
val
 MIGRATION_1_TO_2 = Migration1To2() 
}
You'll use this companion object to store a reference to all the migrations that you'll 
define later.
Now, open 

Download 19,28 Mb.

Do'stlaringiz bilan baham:
1   ...   184   185   186   187   188   189   190   191   ...   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