Content Provider – Part 3 – insert, delete, update, getType

Please read the Part 1 and Part 2

insert

First, create the variables needed for an insert

Content provider implement insert delete update and getType, <span>Content Provider – Part 3 – insert, delete, update, getType</span>, KandZ

get the code from the Urimatcher and create a switch statement for every kind of URI. Then insert the new row

Content provider implement insert delete update and getType, <span>Content Provider – Part 3 – insert, delete, update, getType</span>, KandZ

Create the rowUri with the help of ContentUris class and its method withAppendId

Content provider implement insert delete update and getType, <span>Content Provider – Part 3 – insert, delete, update, getType</span>, KandZ

To execute it:

Content provider implement insert delete update and getType, <span>Content Provider – Part 3 – insert, delete, update, getType</span>, KandZ

delete

The same as insert, but change the switch statement

Content provider implement insert delete update and getType, <span>Content Provider – Part 3 – insert, delete, update, getType</span>, KandZ

And you can execute it:

Content provider implement insert delete update and getType, <span>Content Provider – Part 3 – insert, delete, update, getType</span>, KandZ

update

Content provider implement insert delete update and getType, <span>Content Provider – Part 3 – insert, delete, update, getType</span>, KandZ

and execute it :

Content provider implement insert delete update and getType, <span>Content Provider – Part 3 – insert, delete, update, getType</span>, KandZ

getType

It returns the mime type of the data in the Content Provider. And because maybe your app does not fit any common mime type you need to construct your own for each URI in the Content Provider.

Content provider implement insert delete update and getType, <span>Content Provider – Part 3 – insert, delete, update, getType</span>, KandZ

You need to create a mime type for each table and for single line return or multiple line return

Content provider implement insert delete update and getType, <span>Content Provider – Part 3 – insert, delete, update, getType</span>, KandZ

THE END!!!

99840cookie-checkContent Provider – Part 3 – insert, delete, update, getTypeContent Provider – Part 3 – insert, delete, update, getType

Related posts