在 Android Studio 2.3.3 中创建 ContentProvider
Creating a ContentProvider in Android Studio 2.3.3
我正在使用 Android Studio 2.3.3 并试图将内容提供程序组件添加到项目中。即使在尝试了 URI Authorities 条目的许多变体之后,我仍然收到错误 "URI Authorities must be a valid URI authority"。下面显示了一个全新项目的相同结果。这是在 Studio 中工作还是条目有问题?
应该不带content://
前缀,简单到com.package.1;com.package.2
:
这将在 AndroidManifest
中创建以下 <provider>
:
<provider
android:name="com.mydomain.MyContentProvider"
android:authorities="com.example.1;com.example.2"
android:enabled="true"
android:exported="true"></provider>
Uri Authority 是 content://
和下一个斜杠之间的字符串。
具有 com.example
权限的内容提供者将处理任何以 content://com.example
开头的 Uri。
内容提供者无法指定系统中已存在的 Uri 授权。无法安装此类应用。
在此处阅读更多内容:https://developer.android.com/guide/topics/providers/content-provider-creating.html#ContentURI
我正在使用 Android Studio 2.3.3 并试图将内容提供程序组件添加到项目中。即使在尝试了 URI Authorities 条目的许多变体之后,我仍然收到错误 "URI Authorities must be a valid URI authority"。下面显示了一个全新项目的相同结果。这是在 Studio 中工作还是条目有问题?
应该不带content://
前缀,简单到com.package.1;com.package.2
:
这将在 AndroidManifest
中创建以下 <provider>
:
<provider
android:name="com.mydomain.MyContentProvider"
android:authorities="com.example.1;com.example.2"
android:enabled="true"
android:exported="true"></provider>
Uri Authority 是 content://
和下一个斜杠之间的字符串。
具有 com.example
权限的内容提供者将处理任何以 content://com.example
开头的 Uri。
内容提供者无法指定系统中已存在的 Uri 授权。无法安装此类应用。
在此处阅读更多内容:https://developer.android.com/guide/topics/providers/content-provider-creating.html#ContentURI