Here I am attaching the logs :
Caused by: java.lang.IllegalArgumentException: Unknown URI: content://downloads/public_downloads/1587
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:165)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135)
at android.content.ContentProviderProxy.query(ContentProviderNative.java:418)
I am using this code which is working fine.But for the case of download manager it is throwing exception at first line of 'try' block
Cursor cursor = null;
final String column = "_data";
final String[] projection = {
column
};
try {
cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs,
null);
if (cursor != null && cursor.moveToFirst()) {
final int column_index = cursor.getColumnIndexOrThrow(column);
return cursor.getString(column_index);
}
} finally {
if (cursor != null)
cursor.close();
}
return null;
I already tried this: Android getting file path from content URI using contentResolver and this: java.lang.IllegalArgumentException: Unknown URI content and some others related to this question but not any one of them resolves my problem.
The IllegalArgumentException is a subclass of java.lang.RuntimeException. RuntimeException, as the name suggests, occurs when the program is running. Hence, it is not checked at compile-time. When a method is passed illegal or unsuitable arguments, an IllegalArgumentException is thrown.
This can be caused due to several factors like invalid user input, network failure, memory limitations, trying to open a file that does not exist, etc. If an exception occurs, an Exception object is generated, containing the Exception’s whereabouts, name, and type. This must be handled by the program.
If not handled, it gets past to the default Exception handler, resulting in an abnormal termination of the program. The IllegalArgumentException is a subclass of java.lang.RuntimeException. RuntimeException, as the name suggests, occurs when the program is running. Hence, it is not checked at compile-time.
I was getting the same error Unknown URI: content://downloads/public_downloads
. I managed to solve this by changing contentUri and by using InputStream
methods to fetch file from Download directory. In some of devices changing contentUri to content://downloads/my_downloads
works. Checkout this answer for full solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With