Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to find provider info for 'ContentProvider'

I have a problem that I just cannot figure out. I am using Eclipse to create my own Content Provider but keep getting the following error:

[..] ERROR/ActivityThread(1051): Failed to find provider info for my.package.provider.countrycontentprovider

Code found here: http://codepad.org/Rx00HjHd

Main parts:

public class CountryContentProvider extends ContentProvider {      public static final String PROVIDER =           "my.package.provider.countrycontentprovider";     public static final Uri CONTENT_URI =           Uri.parse("content://" + PROVIDER + "/country");     // ...     @Override     public boolean onCreate() { return true; }     // ... }   // from my activity ContentResolver resolver = getContentResolver(); Cursor c = resolver.query(CountryContentProvider.CONTENT_URI,                                    null, null, null, null);    // AndroidManifest.xml <provider     android:name="my.package.provider.CountryContentProvider"     android:authorities="my.package.provider.countrycontentprovider" /> 

I have added the provider to the manifest and return true from the onCreate function. I use the CountryContentProvider.CONTENT_URI in my activity to get the Content from my provider, but I just keep getting that error message. I have removed and added the code three times (in case of eclipse melt down) to no avail.
I must be missing something. Can someone point me in the right direction?

like image 216
default Avatar asked Sep 18 '11 17:09

default


People also ask

How can an application activate ContentProvider?

Create a class in the same directory where the that MainActivity file resides and this class must extend the ContentProvider base class. To access the content, define a content provider URI address. Create a database to store the application data. Implement the six abstract methods of ContentProvider class.

How do I access my 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 ContentProvider in Android?

A content provider component supplies data from one application to others on request. Such requests are handled by the methods of the ContentResolver class. A content provider can use different ways to store its data and the data can be stored in a database, in files, or even over a network.

What is authority in content provider in Android?

A content URI is a URI that identifies data in a provider. Content URIs include the symbolic name of the entire provider (its authority) and a name that points to a table or file (a path).


2 Answers

I was able to reproduce your problem when I moved <provider> out of the <application>...</application> tag. Eclipse didn't say anything like error or warning.

Fortunately this issue is detected by Android Lint starting from ADT 20.

like image 181
Darth Beleg Avatar answered Sep 17 '22 11:09

Darth Beleg


It worked for me only after specifying full path in Authorities tag in manifest file (see SearchableDictionary sample code in SDK).

<provider android:name=".DictionaryProvider"        android:authorities="com.example.android.searchabledict.DictionaryProvider"> 
like image 43
andude Avatar answered Sep 16 '22 11:09

andude