这里我正在附上日志:
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)
我正在使用这段代码,它运行得很好。但是对于下载管理器的情况,它会在“尝试”块的第一行抛出异常。
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;
我已经尝试过这个:Android使用contentResolver从content URI获取文件路径 和这个:java.lang.IllegalArgumentException: Unknown URI content 还有一些与此问题相关的其他内容,但没有一个可以解决我的问题。
query(uri, projection, selection, selectionArgs, null);
中获取到了所有所需的东西吗? - Ümañg ßürmån