我们试图获取保存在SD卡中的文件路径,并将其传递给一个实用程序。然而,当我们使用URI打开游标时,只有两列被提取,路径(_data列)缺失。请告诉我如何获取路径。该查询对于任何存储在内部存储中的文件都有效。
方案为“content”。
代码片段:
方案为“content”。
代码片段:
cursor = context.getContentResolver().query(uri, null, null, null, null);
if (null != cursor && cursor.moveToFirst())
{
int testcolCount = cursor.getColumnCount();
for (int i = 0; i < testcolCount; i++)
{
String colName = cursor.getColumnName(i);
String colValue = cursor.getString(i);
System.out.println("" + i + ": " + colName + ":" + colValue + "\n");
}
//This prints only two columns, _display_name and _size
}