我正在尝试从uri
获取文件名和文件路径 uri是content://com.android.providers.media.documents/document/audio%3A180
我在尝试:
Uri filePathUri = uri;
if (uri.getScheme().toString().compareTo("content")==0)
{
String[] proj = { MediaStore.Images.Media.DATA };
Cursor cursor = context.getContentResolver().query(uri, null, null, null, null);
if (cursor.moveToFirst())
{
int column_index =
cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DATA);
filePathUri = Uri.parse(cursor.getString(column_index));
fileName = filePathUri.getLastPathSegment().toString();
}
}
我在cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DATA);
java.lang.IllegalArgumentException: column '_data' does not exist
如何获取文件名