这是我获取的文件路径 content://com.tencent.mm.external.fileprovider/attachment/1_双模vd108 87.pdf
获取文件的方法
File destFile = new File(getFilesDir(), "copied_file.pdf"); // 修改文件名和类型
try (
InputStream inputStream = getContentResolver().openInputStream(uri);
OutputStream outputStream = new FileOutputStream(destFile)) {
Log.d(Constents.LOGOUTCS, "inputStream" + inputStream);
Log.d(Constents.LOGOUTCS, "outputStream" + outputStream);
byte[] buffer = new byte[1024];
int bytesRead;
while ((bytesRead = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);
}
} catch (Exception e) {
e.printStackTrace();
}
在 getContentResolver().openInputStream(uri)
报错如下
java.lang.SecurityException: Permission Denial: reading android.support.v4.content.FileProvider uri content://com.tencent.mm.external.fileprovider/attachment/1_双模vd108 87.pdf from pid=26273, uid=10316 requires the provider be exported, or grantUriPermission()
你好,平台不会返回Java报错