如何解决如何从存储中获取选定的文件路径?
我的活动结果是
@Override
protected void onActivityResult(int requestCode,int resultCode,Intent data) {
super.onActivityResult(requestCode,resultCode,data);
if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
try {
if (data == null) {
try {
String pathSource = DataUtil.getRealPathFromURI(context,lastCaptureRequestUri);
DataUtil.scaleDownImage(pathSource,lastCaptureRequestUri.getPath());
photoUriList = lastCaptureRequestUri;
sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE,lastCaptureRequestUri));
refreshLayoutImage();
} catch (Exception e) {
e.printStackTrace();
exceptionAnalytics(e);
}
} else {
Uri selectedImageUri = data.getData();
// image picked now shrink image to lastCaptureRequestUri
try {
String pathSource = DataUtil.getRealPathFromURI(context,selectedImageUri);
DataUtil.scaleDownImage(pathSource,lastCaptureRequestUri.getPath());
photoUriList = lastCaptureRequestUri;
sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE,lastCaptureRequestUri));
refreshLayoutImage();
} catch (FileNotFoundException e) {
Toast.makeText(context,getString(R.string.selected_file_not_found),Toast.LENGTH_SHORT).show();
e.printStackTrace();
exceptionAnalytics(e);
} catch (Exception e) {
e.printStackTrace();
exceptionAnalytics(e);
}
}
} catch (Exception e) {
e.printStackTrace();
exceptionAnalytics(e);
}
} else if (requestCode == REQUEST_PDF_CAPTURE && resultCode == RESULT_OK) {
Log.i("photoUriList__",photoUriList + "--");
if (data != null && data.getData() != null) {
photoUriList = data.getData();
imgvTestReport.setImageResource(R.drawable.ic_picture_as_pdf_black_36dp);
reportImage = new File(photoUriList.getPath());
}
}
}
我正在从roo_path获取路径
/ root_path / storage / emulated / 0 / WhatsApp / Media / WhatsApp Documents / abc.pdf
但是我要从存储中进行存储,如下所述
存储/模拟/ 0 / WhatsApp / Media / WhatsApp文档/abc.pdf
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。