1

I'm using Android Studio 2.3.3 and was trying to add a Content Provider component to the project. I keep getting the error "URI Authorities must be a valid URI authority" even after trying many variants of the URI Authorities entry. Same results for a brand new project shown below. Is this working in Studio or is something wrong with the entry?

Android Studio Configure Component

azizbekian
  • 60,783
  • 13
  • 169
  • 249
Hankster
  • 422
  • 3
  • 9

2 Answers2

5

It should be without content:// prefix, as simple as com.package.1;com.package.2:

enter image description here

This will create following <provider> in AndroidManifest:

    <provider
        android:name="com.mydomain.MyContentProvider"
        android:authorities="com.example.1;com.example.2"
        android:enabled="true"
        android:exported="true"></provider>
azizbekian
  • 60,783
  • 13
  • 169
  • 249
2

Uri Authority is the string between content:// and the next slash.

A content provider with com.example authority will handle any Uri starting with content://com.example.

A content provider cannot specify an Uri Authority that's already present in the system. Such app cannot be installed.

Read more here: https://developer.android.com/guide/topics/providers/content-provider-creating.html#ContentURI

Eugen Pechanec
  • 37,669
  • 7
  • 103
  • 124