3

When I call an Android ContentProvider I get the following exception:

java.lang.RuntimeException: Unable to start activity ComponentInfo{de.harm.android.couchone/de.harm.android.couchone.CouchContactClient}: java.lang.IllegalArgumentException: Unknown URL content://de.harm.android.couchone.provider/test2

These are the projects:

Android uses the so-called ContentResolver to communicate with ContentProvider which in turn handles the persistence functionality - accessing the database.

The ContentProvider registers itself with a unique Uri. The ContentResolver calls the ContentProvider with this Uri and passes additional data, like a SQL query string and/or data to be saved.

In the CouchOneProvider/AndroidManifest.xml I have the following:

<provider android:authorities="de.harm.android.couchone.provider"
   android:name=".Provider" />

The Provider uses

static {
    uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
    uriMatcher.addURI(PROVIDER_NAME, DB_Name, URI_COLLECTION);
    uriMatcher.addURI(PROVIDER_NAME, DB_Name + "/#", URI_ENTITY);
}

and

public static boolean isCollectionUri(Uri uri) {
    return uriMatcher.match(uri) == URI_COLLECTION;
}

to process the CONTENT_URI used by the ContentResolver to call the ContentProvider:

  • Am I missing permissions in any of both AndroidManifest.xml?
  • Am I defining the authority in AndroidManifest.xml wrongly?
  • Is the CONTENT_URI wrong?

Update:

I have additional information:

Logcat says:

Failed to find provider info for de.harm.android.couchone.provider

This should be the starting point. But so far I couldn't find any solution.

The fully qualified classname of the ContentProvider implementation is:

de.harm.android.couchone.Provider

In AndroidManifext.xml exactly this is specified as authority, except for the name being to lower case, but this should be fine.

The package name is defined previously in the xml file, so ".Provider" should be ok, too.

As to be seen in the exception, the client calls:

content://de.harm.android.couchone.provider/test2

Logcats answer is:

Failed to find provider info for de.harm.android.couchone.provider

I don't see what's missing, perhaps it's Eclipse or emulator problem?

I install the provider as "run project as Android application".

4

2 回答 2

3

我已经解决了这个问题:

这两个项目具有相同的包结构。我de.harm.android.couchone改为de.harm.android.couchone.providerde.harm.android.couchone.client

于 2010-12-14T10:06:15.683 回答
0

我认为这个链接与问题主题有关。如何实现自定义内容提供者

于 2012-05-28T06:34:58.227 回答