ToDoAdapter.kt
and find
insertToDo
. Replace the comment in the body
with:
// 1
var
values = ContentValues()
values.put(KEY_TODO_NAME, toDoName)
// 2
context.contentResolver.insert(CONTENT_URI, values)
1. Create and populate a content values object.
2. Run the insert query on the content resolver to insert the record.
After all your hard work it is time to run the app and add a couple items! Build and
run the app. Click the button in the lower left corner and add some items to your
TODO list. They will be displayed in the list as you add them. Nice work! :] Note that
"update" and "delete" buttons will not actually do anything, yet. You'll add the
functionality to update (edit) an item, next.
Saving Data on Android
Chapter 4: ContentProvider
raywenderlich.com
85
Do'stlaringiz bilan baham: |