Search code examples
androidandroid-contentprovider

Content Provider commons


Few interesting questions about Content Provider mechanism

  • Should we use Content Provider, when data are not meant to be shared accross applications?

Content providers store and retrieve data and make it accessible to all applications. They're the only way to share data across applications; there's no common storage area that all Android packages can access.
http://developer.android.com/guide/topics/providers/content-providers.html

  • When having multiple data tables connected together, should we create single Provider for every data type, or can we use single provider for all of them?

  • When mirroring data from remote server, is there any common update mechanism related to Content Provider, or do we have to implement some kind of SyncAdapter ?


Solution

  • Should we use Content Provider, when data are not meant to be shared across applications?

    Content Provider is one of the good features to share data among applications or activities within applications. If you want to use content provider for your application and don't want to share then you can use content provider and it is really nice abstraction if you use content provider.

    When having multiple data tables connected together, should we create single Provider for every data type, or can we use single provider for all of them?

    For different tables I think you have to create different content provider.In Android there are different content provider for different tables and database.So better you create separate content provider for all the tables.