Implemen/ng insert
Open
ToDoContentProvider.kt
and replace the
TODO
in the body of the insert
method with the following code:
val
id = db.insert(values!!.getAsString(KEY_TODO_NAME))
return
Uri.parse(
"
$CONTENT_URI
/
$id
"
)
If you have multiple import options for
KEY_TODO_NAME
, use
import
com.raywenderlich.contentprovidertodo.Controller.provider.ToDoCo
ntract.ToDoTable.Columns.KEY_TODO_NAME
When inserting a to-do item, the only relevant information that is provided is the
name of that item. Completed is false by default and the id field is provided by the
insert method itself. The database handler returns the id, and the content provider
uses this id to return a URI where this provider can access the new record.
Next, open
Do'stlaringiz bilan baham: |