This project is read-only.

Content provider in Sample

Feb 17, 2012 at 5:24 PM

Hello... First of all I want to thank you for the sample implementation with android. It have been really helpfull to me.

I want to ask you some questions about it.

- Why do you use a content provider in android?  if we don't need to share data with another android apps why use it?  don't we should just consume the JSON data and do regular inserts and updates with de SQLlite class?

- Do you use the ContentProvider and authentication services so that you can call the sync with the contentresolver.requestsync ??

- How does the contentresolver works? In wich moment does  it call the SyncService class to start the syncAdapter's onperformsync method?

Thanks for your time, and again thanks for the sample. 

Luis Mejia. 

Apr 4, 2012 at 11:24 AM
Edited Jan 25, 2013 at 2:26 PM


Sorry that you have to wait so long, i didn't get notification about new discussion ...

Why i'm using CP(ContentProvider):

1. i was inspired by presentation from Google I/O

2. CP adds new layer of abstraction so we can add sync specific operation there (like setting isDirty, isDeleted flags on row), surley we can use triggers but ...

3. i really like CPs and i think this is the android way for data access ...

4. there is a lots of problem with SQLiteOpenHelper and SQLiteDatabes instances(i mean if there is more than one) and if i understand docs correctly this class was created to help implementing CPs... 


Q: "do you use the CP ...?"

A: yes, but as i wrote before this is not the only cause


Q: "How does the ....?"

A: AFAIF, no, calling ContentResolver.requestSync will not immediately start sync ... if i understand docs correctly it will be queued in android internal sync manager and run later but this ("later" deppends on internet connection availableity, errors occurred in prevs sync with the same account, other accounts sync queue ... so it could be few miliseconds after requestSync or even few minutes later ...)

but still you can use code bellow to sync immediately: 

Uri uri = YourProviderClass.getSyncUri("Service", "DefaultScope");
getContentResolver().update(uri, null, "?template_param=value", null);