Saving Data on Android



Download 19,28 Mb.
Pdf ko'rish
bet93/292
Sana24.01.2022
Hajmi19,28 Mb.
#407089
1   ...   89   90   91   92   93   94   95   96   ...   292
Bog'liq
Bailey J., Dominguez A., Djermanovic D. - Saving Data on Android (1st Edition) - 2019

Implemen/ng onCreate
Insert the code below into the 
onCreate
 method stub replacing the 
TODO
 marker:
db = ToDoDatabaseHandler(context)    
initializeUriMatching() 
return
 
true
The 
onCreate
 prepares the content provider by instantiating the database handler 
object, calling the 
initializeUriMatching
 function to initialize the URI matcher, and 
returns true to signal that this content provider was created successfully.
Implemen/ng getType
Next, implement the 
getType
 function by replacing the entire stub with the code 
below:
Saving Data on Android
Chapter 4: ContentProvider
raywenderlich.com
82


override
 
fun
 
getType
(uri: Uri)
 : String? = 
when
(sUriMatcher.match(uri)) { 
  URI_ALL_ITEMS_CODE -> MULTIPLE_RECORDS_MIME_TYPE 
  URI_ONE_ITEM_CODE -> SINGLE_RECORD_MIME_TYPE 
  
else
 -> 
null
 
}
The 
getType
 function accepts a Uri and matches it with the  URI code. Then it 
returns the correct MIME type. These constants are defined in the contract that has 
made the code for this function more self-descriptive.
Now that the trivial details are out of the way, the CRUD operations of the content 
provider can be implemented.

Download 19,28 Mb.

Do'stlaringiz bilan baham:
1   ...   89   90   91   92   93   94   95   96   ...   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