Search code examples
androidsqliteandroid-serviceandroid-contentprovider

Content Provider vs Remote Service to share db access between applications?


  • What are advantages and disadvantages of these two approaches (for android 4+)?
  • Direct SQLite access vs Content Provider for big volume of data?

Thanks.


Solution

  • Although this is really a bad question without any detail at all, I would like to give my thoughts about this.

    We talked this a lot in our company. I was left with DB sharing code that is implemented using AIDL to share the data across processes. The problem was that it was too complicated. There were layers of classes to access to the Service to bind.

    I removed those AIDL files and services and wrote a ContentProvider. I used the following library and it is really helpful. https://github.com/TimotheeJeannin/ProviGen

    We are going to give the DB access publicly to the 3rd party developers. So I also wrote an SDK that wraps the common operations of the database like query/insert/delete. They can for example just give an object to delete and the SDK convert that to a DELETE ContentProvider query. But we also expose the column names and CONTENT_URI for the DB to be used in ContentLoader which is really really good. And we use Loaders internally.