【发布时间】:2013-12-02 18:24:59
【问题描述】:
在Android 4.4 (KitKat) 中的新图库访问之前,我通过这种方法在 SD 卡上获得了我的真实路径:
public String getPath(Uri uri) {
String[] projection = { MediaStore.Images.Media.DATA };
Cursor cursor = managedQuery(uri, projection, null, null, null);
startManagingCursor(cursor);
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
}
现在,Intent.ACTION_GET_CONTENT 返回不同的数据:
之前:
content://media/external/images/media/62
现在:
content://com.android.providers.media.documents/document/image:62
我怎样才能获得 SD 卡上的真实路径?
【问题讨论】:
-
我想你可以在这里找到解决方案stackoverflow.com/questions/19834842/…
-
你真的需要路径吗?也许您只是想从 URI 中获取 Bitmap 对象?如果是这样,我有一个解决方案。
-
是的,我真的需要一个路径,我想从新的存储访问框架中获取它。我的临时解决方案是避免使用新的存储访问。我已将 Intent.ACTION_GET_CONTENT 更改为 Intent.ACTION_PICK
-
@Alvaro,你最后做了什么
-
在 4.4.2 版本中无法从我的应用程序中选择谷歌驱动器中的项目。我完全被困住了?任何解决方案
标签: android path uri android-4.4-kitkat