Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I catch content provider initialize?

Tags:

As we know content provider loads on application run. But I want to make some operations before content provider will launch. How do I catch this operation? Before content provider's onCreate method would be called

like image 569
pleerock Avatar asked Mar 26 '12 14:03

pleerock


People also ask

How do you initialize a content provider?

The primary methods that need to be implemented are: onCreate() which is called to initialize the provider. query(Uri, String[], Bundle, CancellationSignal) which returns data to the caller. insert(Uri, ContentValues) which inserts new data into the content provider.

How do you query content provider?

Accessing a provider. When you want to access data in a content provider, you use the ContentResolver object in your application's Context to communicate with the provider as a client. The ContentResolver object communicates with the provider object, an instance of a class that implements ContentProvider .

What is the purpose of 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.

How can I access my content provider from another application?

After creating the content provider , specify the content provider in the manifest file. You can mention content provider using the tag. Inside the provider tag dont forget to mention the name and authorities attributes. This declaration should be ..


1 Answers

I think Ive found solution. Ive created my custom application class and overridden attachBaseContext method

<application android:name=".ApplicationController" ...> 

public class ApplicationController extends Application {     @Override     protected void attachBaseContext(Context base) {         super.attachBaseContext(base);          // some of your own operations before content provider will launch     } } 
like image 180
pleerock Avatar answered Oct 15 '22 23:10

pleerock