What are the benefits of using ContentProvider over regular SQLIte repository?

I want to exchange data between several applications, instead of having the mechanism ContentResolver-> ContentProvider, can I just define a client library that says about the process that performs SQLite DB operations correctly?

What does ContentProvider offer, what cannot we achieve if the process exposes data?

+4
source share
2 answers

You may find the answer The exact difference between the "Content-Provider" and the "SQLite Database" .

But I like to explain it.

What does the ContentProvider brings in here which we cannot achieve by have a Process expose the data? 

There is one specific SQLite limitation that you should be aware of, and that SQLite is single-user. In fact, this means that you will need to protect your database from access from multiple threads at the same time. This is usually not a problem with the content provider, as they almost always have a single-threaded implementation.

It's also good practice to provide an extra layer of abstraction over your data in order to simplify the change internally. What if you decide to change the basic structure of the database later? If you use a ContentProvider , you can contain all the structural changes inside it, where, as if you hadn't used it, you are forced to change all areas of the code that are affected by the structural changes. It’s also nice to be able to reuse the same standard API to access data, rather than clog your code with low-level database access.

+8
source

All Articles