java.lang.SecurityException: Permission Denial: opening provider com.android.providers.media.MediaDocumentsProvider from ProcessRecord{6f31548 13761:com.spotbros.enterprise/u0a88} (pid=13761, uid=10088) requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs
and this is the code where i catch the exception:
if (scheme.equals("content")) {
Cursor c = null;
try {
c = SpotbrosApplication.getAppContext().getContentResolver().query(uri, null, null, null, null);
int dataColumnIndex = c.getColumnIndex(MediaStore.MediaColumns.DATA);
if (dataColumnIndex != -1) {
// Simplest case: the query returns a column named "_data" with the file real path.
if (!c.moveToFirst()) {
// The cursor returned empty for any reason.
return null;
}
return c.getString(dataColumnIndex);
}
/*
* The query has not returned the "_data" column, so, as far as we know, the file may well be coming in
* from Google Drive over Lollipop.
*/
return copyGDriveFileToFilesFolder(SpotbrosApplication.getAppContext(), uri);
} catch (Exception e) {
e.printStackTrace();
return null;
} finally {
if (c != null) {
c.close();
}
}
}