Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why should I use custom content provider in Android?

What are advantages of using custom content provider? Why such content provider is superior of plain class that wraps SQL queries?

like image 782
pixel Avatar asked Nov 02 '10 15:11

pixel


People also ask

Why do we need content provider in Android?

Content providers can help an application manage access to data stored by itself, stored by other apps, and provide a way to share data with other apps. They encapsulate the data, and provide mechanisms for defining data security.

What is the difference between content provider and SQLite database in Android?

That is to say, a SQLite database created on Android by one application is usable only by that application, not by other applications. So, if you need to share data between applications, you need to use the content provider model as recommended in Android.

How can I use custom content provider in another Android app?

To use content provider, you need to use ContentResolver object in your application's context which is then used to communicate with the provider. You need to develop your own Provider if: You want to share your data with other applications. You want to provide custom search suggestions in your own application.

How many ContentProvider Can an app have?

You can implement as many as you want, as you can see from the documentation here. To register a content provider, you need to add its corresponding <provider> tag in the Android Manifest. In most cases, however, you won't need multiple content providers. One is usually enough, as it can handle multiple tables.


1 Answers

Content providers can be used from other processes and are required by some mechanisms on Android like the global search. There are also some classes available that help you deal with content providers that save you some of the hassle of manging memory.

like image 57
kichik Avatar answered Nov 15 '22 00:11

kichik