Rohit
Rohit

Reputation: 665

java.lang.IllegalArgumentException: Unknown URL file at android.content.ContentResolver.delete

Getting the above error

builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
                    @Override
                    public void onCancel(DialogInterface dialog) {

                        if (mImageCaptureUri != null)
                        {
                            //exception at below line
                            getContentResolver().delete(mImageCaptureUri, null,null);
                            mImageCaptureUri = null;
                        }
                    }
                });

I tried checking if file exists by new File(mImageCaptureUri.getPath()).exists() it exists but still I'm getting the exception as

java.lang.IllegalArgumentException: Unknown URL file:///storage/sdcard0/tmp_avatar_1412858553212.jpg    
at android.content.ContentResolver.delete(ContentResolver.java:984) 

Upvotes: 0

Views: 4314

Answers (1)

CommonsWare
CommonsWare

Reputation: 1007349

I tried checking if file exists by new File(mImageCaptureUri.getPath()).exists() it exists

Note that there is no requirement that a Uri point to a file that you can access.

still i'm getting the exception as

java.lang.IllegalArgumentException: Unknown URL file:///storage/sdcard0/tmp_avatar_1412858553212.jpg at android.content.ContentResolver.delete(ContentResolver.java:984) 

ContentResolver is mostly for content:// schemes. For a file:// scheme, you may need to try deleting the file directly yourself.

Upvotes: 2

Related Questions