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?
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.
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 .
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.
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).
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.
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">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With