我在下面的android代碼中得到了未知的URL異常「java.lang.IllegalArgumentException:Unknown URL content://com.abcd/metertable」,成爲它的原因。是否有人可以幫助,在此先感謝:獲取「java.lang.IllegalArgumentException:URL中的未知內容」Android
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
}
URI:
public static final String PACKAGE = "com.abcd";
public static final String TABLE = "table";
public static final Uri CONTENT_URI = Uri.parse("content://"+ PACKAGE + "/" + TABLE);
感謝兄弟:)一直在同一問題掙扎超過2小時..最終解決:) –