2

I am getting Unknown URL exception "java.lang.IllegalArgumentException: Unknown URL content://com.abcd/metertable" in my below android code, What could be reason for it. Can someone please help, Thanks in advance :

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 :

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

Code :

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);

3 Answers 3

3

android:authorities should not be the class you define, but the uriauthorities. it should be like this:

<provider android:name="com.abcd.meters.myclass"
          android:authorities="com.abcd">
</provider>
Sign up to request clarification or add additional context in comments.

Comments

1

The error says that you are trying to access content://com.abcd/metertable, where the "authority" is "com.abcd".

The AndroidManifest provider tag has only defined the authority of "com.abcd.myclass".

If you match those, then the provider will work.

1 Comment

thanks bro :) had been struggling with the same issue for more than 2 hrs..finally solved :)
0

If Android 11 (API level 30) or above add queries:

<queries>
    <package android:name="com.example.your_app"/>
</queries>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.