Search code examples
androiddatabaserestsynchronizationandroid-contentprovider

Is an Android ContentProvider absolutely necessary for syncing?


I am trying to write an application that synchronises data stored locally on an Android phone with data stored on a remote database on a server elsewhere. Of course, there will be an UI screen available on the phone where the user can view/edit the data.

I have decided to do the syncing via a RESTful web service and have watched the Google I/0 2010 video that explains 3 various design patterns for creating an Android REST client. They all have one component in common - a Content Provider.

I was wondering if it is absolutely necessary to create a Content Provider for accessing the data as I will only be accessing it within my application, or is it necessary because the synchronisation code will need to run in its own process?.

Thank you for your help!.


Solution

  • No it's not necessary to use a content provider. You can write a class that retrieves data from a server and run this process in a AsyncTask. Keep in mind that the retrieval of data should never lock your UI.