我在下面的 android 代码中收到未知 URL 异常“java.lang.IllegalArgumentException:未知 URL 内容://com.abcd/metertable”,这可能是什么原因。有人可以帮忙吗,在此先感谢:
java.lang.IllegalArgumentException: Unknown URL content://com.abcd/table
at android.content.ContentResolver.delete(ContentResolver.java:955)
at com.abcd.Class.mymethod(Class.java:536)
at com.abcd.Class.access$8(Class.java:530)
at com.abcd.Class$MeterTask.onPostExecute(Class.java:290)
at com.abcd.Class$MeterTask.onPostExecute(Class.java:1)
at android.os.AsyncTask.finish(AsyncTask.java:631)
at android.os.AsyncTask.access$600(AsyncTask.java:177)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4849)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
at dalvik.system.NativeStart.main(Native Method)
提供者:
<provider android:name="com.abcd.meters.Class2"
android:authorities="com.abcd.myclass">
</provider>
代码 :
private void mymethod()
{
ContentResolver crol = context.getContentResolver();
int rows = crol.delete(MyClass.CONTENT_URI, MyClass.MARK_FOR_DELETE + "=1", null);
Log.d(TAG, rows + " rows deleted");
// Count records to upload
}
网址:
public static final String PACKAGE = "com.abcd";
public static final String TABLE = "table";
public static final Uri CONTENT_URI = Uri.parse("content://"+ PACKAGE + "/" + TABLE);