Saving Data on Android



Download 19,28 Mb.
Pdf ko'rish
bet193/292
Sana24.01.2022
Hajmi19,28 Mb.
#407089
1   ...   189   190   191   192   193   194   195   196   ...   292
Bog'liq
Bailey J., Dominguez A., Djermanovic D. - Saving Data on Android (1st Edition) - 2019

QuizApplication.kt
 file and add your new migration to the database 
builder:
database = Room.databaseBuilder(
this
, QuizDatabase::
class
.
java

"question_database")
 
    .addMigrations( 
      QuizDatabase.MIGRATION_1_TO_2,  
      QuizDatabase.MIGRATION_2_TO_3, 
      QuizDatabase.MIGRATION_3_TO_4,  
      QuizDatabase.MIGRATION_1_TO_4 
    ).build()
Cool! You now have a migration that goes directly from database version 1 to 4. If 
you build the app, the migration won't execute since your app is already on database 
version 4, but you can now be sure that all your users on database version 1 will 
properly migrate to the new version when they update the app.
Saving Data on Android
Chapter 10: Migrations with Room
raywenderlich.com
185


Key points
• Simply put, a database migration or schema migration is the process of moving 
your data from one database schema to another.
• SQLite handles database migrations by specifying a version number for each 
database schema that you create.
• Room provides an abstraction layer on top of the traditional SQLite migration 
methods with 
Migration
.

Migration(startVersion, endVersion)
 is the base class for a database 
migration. It can move between 
any
 two migrations defined by the 
startVersion
 
and 
endVersion
 parameters.

fallbackToDestructiveMigration()
 tells Room to destructively recreate tables 
if you haven't specified a migration.

Download 19,28 Mb.

Do'stlaringiz bilan baham:
1   ...   189   190   191   192   193   194   195   196   ...   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