这是我遇到的错误:
Caused by: java.lang.IllegalArgumentException: Unknown URL content://com.new.newapp.locations/locations
at android.content.ContentResolver.insert(ContentResolver.java:1213)
at com.new.newapp.activity.FragmentGoogleMap$LocationInsertTask.doInBackground(FragmentGoogleMap.java:364)
at com.new.newapp.activity.FragmentGoogleMap$LocationInsertTask.doInBackground(FragmentGoogleMap.java:360)
我研究了这个问题并发现了这些类似的问题: Link1 Link2 Link3
这些都没有帮助。最让我困扰的是,当我使用 eclipse 时,我没有遇到这个问题,但自从在 Android Studio 上工作后,我似乎无法让它工作。
在我的 LocationsContentProvider
类中:
package com.new.newapp.activity;
public class LocationsContentProvider extends ContentProvider{
public static final String PROVIDER_NAME ="com.new.newapp.activtiy.locations";
public static final Uri CONTENT_URI = Uri.parse("content://" + PROVIDER_NAME + "/locations" );
private static final int LOCATIONS = 1;
private static final UriMatcher uriMatcher ;
static {
uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
uriMatcher.addURI(PROVIDER_NAME, "locations", LOCATIONS);
}
LocationsDB mLocationsDB;
在我的 list 中我有这个:
</activity>
<provider
android:name="com.new.newapp.activity.LocationsContentProvider"
android:authorities="locations"
android:exported="false" />
</application>
我试过 android:authorities="com.new.newapp.activity.locations"
我也试过 android:name=".LocationsContentProvider"
也搬家了
有人可以帮忙吗?
最佳答案
您的问题在于提供商名称。
<provider
android:name="com.new.newapp.activity.LocationsContentProvider"
android:authorities="locations"
android:exported="false" />
public static final String PROVIDER_NAME ="com.new.newapp.activtiy.locations";
应该是
public static final String PROVIDER_NAME ="com.new.newapp.activity.LocationsContentProvider";
关于android - 如何在android studio中修复 "Unknown URL content://com.new.newapp.locations/locations",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32023122/