我想要android中uri的pdf文件的真实路径

时间:2019-07-17 18:41:42

标签: android file pdf uri

我正在尝试获取pdf文件的路径,但是stackoverflow中提供的所有解决方案均返回null。

String path;<br>
String[] proj = { MediaStore.Files.FileColumns.DATA };<br>
Cursor cursor = getContentResolver().query(uri, proj, null, null, null);<br>
if (cursor == null) {
   path = uri.getPath();
} else {
   cursor.moveToFirst();
   int idx = cursor.getColumnIndex(MediaStore.Files.FileColumns.DATA);
   path = cursor.getString(idx);
   cursor.close();
}
filePath.setText(path);

0 个答案:

没有答案