gpt4 book ai didi

android - 获取 "java.lang.IllegalArgumentException: Unknown URL content in"Android

转载 作者:搜寻专家 更新时间:2023-11-01 08:02:31 27 4
gpt4 key购买 nike

我在下面的 android 代码中收到未知 URL 异常“java.lang.IllegalArgumentException:未知 URL content://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);

最佳答案

android:authorities 不应该是你定义的类,而是 uriauthorities。它应该是这样的:

<provider android:name="com.abcd.meters.myclass"
android:authorities="com.abcd">
</provider>

关于android - 获取 "java.lang.IllegalArgumentException: Unknown URL content in"Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19045202/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com