I am trying to get the filename and filepath from uri
the uri is content://com.android.providers.media.documents/document/audio%3A180
I am trying:
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();
}
}
I am getting an error at cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DATA);
java.lang.IllegalArgumentException: column '_data' does not exist
How to get the filename