Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is ContentProviderOperation used for

Tags:

android

I see this project http://code.google.com/p/iosched/ in io like LocalRoomsHandler.java have "ContentProviderOperation" but I can't understand what is used for It's only used for contacts? Who can give me an answer

like image 272
JasonYun Avatar asked Mar 13 '11 12:03

JasonYun


2 Answers

ContentProviderOperation enables mainly to batch operations on a Content provider : ex :

ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>(lRosterContentCount);

Builder cpo = ContentProviderOperation.newUpdate(ProviderConstants.CONTENT_URI);
cpo.withValues(Entries);
cpo.withSelection(SQLTables.ID + "=?", selection);
ops.add(cpo.build());

etc.. You can prepare a lot of "Operation", and at the end you call one time :

ContentProviderResult[] results = ContentResolver.applyBatch(ProviderConstants.CP_AUTHORITY_DB, ops);
like image 58
Guillaume13 Avatar answered Nov 10 '22 00:11

Guillaume13


Content Provider facilitates access to a central data store or warehouse to allow data sharing and data manipulation across different applications. These are the only way to access information across application in the same device.

Like their are built in Content Providers in android system like

  • Contacts

  • MediaStore

  • Bookmarks

  • Settings and more.

See this image how Content Provider works(Image courtsey -- http://vajjala-javapassion.blogspot.in/2011/08/getting-started-with-android-content.html)

enter image description here

See this image, Points to be noted:

  1. Content providers has access to different data sources like database, File, Xml e.t.c.

  2. Activities from different application are using this Content Providers.

  3. Content Provider is a bridge between Data resources and different application.

like image 30
Nikhil Agrawal Avatar answered Nov 10 '22 01:11

Nikhil Agrawal