Creating and Using ContentProvider for Android

When I call 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 ContentResolverto communicate with ContentProvider, which, in turn, processes the save function - access to the database.

ContentProviderlogs in with a unique Uri. ContentResolvercalls ContentProviderUri with this and passes additional data, such as the SQL query string and / or data that needs to be saved.

The CouchOneProvider/ AndroidManifest.xmlI have the following:

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

Supplier 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;
}

for the processing CONTENT_URIused ContentResolverto call ContentProvider:

  • Am I missing permissions in any of AndroidManifest.xml?
  • Am I defining permissions in AndroidManifest.xml?
  • Wrong CONTENT_URI?

Update:

I have additional information:

Logcat says:

Could not find provider information for de.harm.android.couchone.provider

This should be the starting point. But so far I have not been able to find a solution.

Full name of the implementation class ContentProvider:

de.harm.android.couchone.Provider

This is AndroidManifext.xmlexactly stated as an authority, except that the name is lowercase, but that should be fine.

The package name is defined earlier in the XML file, so ".Provider" should also be in order.

, :

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

:

de.harm.android.couchone.provider

, , , Eclipse ?

" Android".

+3
2

:

. de.harm.android.couchone de.harm.android.couchone.provider de.harm.android.couchone.client.

+3

, . -.

0

Source: https://habr.com/ru/post/1779515/


All Articles