Saving Data on Android


Crea/ng the database constants using a



Download 19,28 Mb.
Pdf ko'rish
bet59/292
Sana24.01.2022
Hajmi19,28 Mb.
#407089
1   ...   55   56   57   58   59   60   61   62   ...   292
Bog'liq
Bailey J., Dominguez A., Djermanovic D. - Saving Data on Android (1st Edition) - 2019

Crea/ng the database constants using a 
contract class
In the 
Model
, create a new file and name it 
TodoDbSchema.kt
. Place the following 
code into the file:
object
 ToDoDbSchema { 
  
// 1
 
  const 
val
 DATABASE_VERSION = 
1
 
  
// 2
 
  const 
val
 DATABASE_NAME = 
"todoitems.db"
 
  
object
 ToDoTable { 
    
// 3
 
    const 
val
 TABLE_NAME = 
"todoitems"
 
    
object
 Columns { 
      
// 4
 
      const 
val
 KEY_TODO_ID = 
"todoid"
  
      
// 5
 
      const 
val
 KEY_TODO_NAME = 
"todoname"
  
      
// 6
 
      const 
val
 KEY_TODO_IS_COMPLETED = 
"iscompleted"
  
    } 
  } 
}
Here's what each part is:
1. The version of the database. Manually increment this number each time the 
database version is new, and you need to use the version to add 
update
 or 
migration logic
.
2. The name of the database as it will be stored in the app-specific database folder 
on the device.
3. The name of the table will use to store the TODO items.
4. The column that contains the 
unique primary key
 for each TODO item.
5. The column that contains the text of the TODO item.
6. The column that will store a value that will be used to indicate whether or not 
you completed a TODO item.
Now, it's time to create your own database!
Saving Data on Android
Chapter 3: SQLite Database
raywenderlich.com
52



Download 19,28 Mb.

Do'stlaringiz bilan baham:
1   ...   55   56   57   58   59   60   61   62   ...   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