-1
我使用此代码成功获取了视频文件的实际地址。如何在android中获取pdf文件的实际文件路径?
Uri selectedVideo = data.getData();
String[] filePathColumn = {MediaStore.Video.Media.DATA};
Cursor cursor = getContentResolver().query(selectedVideo, filePathColumn, null, null, null);
assert cursor != null;
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
mediaPath1 = cursor.getString(columnIndex);
由于PDF不是媒体文件,我不能使用MediaStore。
使用下面提到的代码给了我“的内容://com.android.providers.media.documents/.....”作为路径
其实我上传使用改造2至服务器的PDF文件。 当我硬编码文件管理器中显示的地址到mediapath1我能够成功上传文件。
我发现了许多从uri获取地址的解决方案,但没有人给我正确的地址。
在此先感谢。
Uri uri = data.getData();
File file = new File(uri.toString());
mediaPath1 = file.getAbsolutePath();
uploadPdf();
,我发现实际问题,同时上传PDF文件到服务器,所以我更新的问题。我无法获得PDF文件的真实文件地址。 – TheDominus