Saving Data on Android



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

queryCountURI
, which is appended with 
/
count
 to query the provider for the count of records instead of returning all the 
records or a single item. Now wouldn't it be neat if another app could utilize these 
queries as well?
Now, find the comment that states 
// TODO: Add query here to get all items
 
in 
onBindViewHolder
. Replace the comment with this code:
// 1
 
val
 cursor = 
context.contentResolver.query(Uri.parse(
"
$queryUri
"
), 
  projection, 
  selectionClause, 
  selectionArgs, sortOrder) 
 
// 2
 
if
(cursor != 
null
) { 
  
if
(cursor.moveToPosition(position)) { 
    
val
 toDoId = 
cursor.getLong(cursor.getColumnIndex(KEY_TODO_ID)) 
    
val
 toDoName = 
cursor.getString(cursor.getColumnIndex(KEY_TODO_NAME)) 
    
val
 toDoCompleted= 
cursor.getInt(cursor.getColumnIndex(KEY_TODO_IS_COMPLETED)) > 
0
 
    
val
 toDo= ToDo(toDoId, toDoName, toDoCompleted) 
    holder.bindViews(toDo) 
  } 
}
Saving Data on Android
Chapter 4: ContentProvider
raywenderlich.com
84


1. Calling 
query
 on the content resolver returns a cursor that will allow the app to 
iterate through all the records in the table, create a to-do item and bind the fields 
of the recycler view's row to the fields of that to-do item.
2. Create a ToDo item from the fields in the query and bind it to the view.
Lastly, add the code to insert a record. Then you can test the basic functionality of 
the content provider.

Download 19,28 Mb.

Do'stlaringiz bilan baham:
1   ...   92   93   94   95   96   97   98   99   ...   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