Aja*_*han 9 android uri android-contentprovider android-download-manager android-8.0-oreo
我在这里附上日志:
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)
Run Code Online (Sandbox Code Playgroud)
我正在使用此代码,效果很好。但是对于下载管理器,它在``try''块的第一行引发异常
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;
Run Code Online (Sandbox Code Playgroud)
我已经尝试过:Android使用contentResolver从内容URI获取文件路径, 并且:java.lang.IllegalArgumentException:未知的URI内容以及与此问题相关的其他一些内容,但没有一个解决了我的问题。
我遇到了同样的错误Unknown URI: content://downloads/public_downloads。我设法通过更改contentUri并使用InputStream从Download目录中获取文件的方法来解决此问题。在某些设备中,将contentUri更改为content://downloads/my_downloads有效。查看此答案以获取完整解决方案。
| 归档时间: |
|
| 查看次数: |
6186 次 |
| 最近记录: |