Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/390.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 要求您使用ACTION\u OPEN\u文档或相关API获得访问权限_Java_Android_Android Studio_Cursor - Fatal编程技术网

Java 要求您使用ACTION\u OPEN\u文档或相关API获得访问权限

Java 要求您使用ACTION\u OPEN\u文档或相关API获得访问权限,java,android,android-studio,cursor,Java,Android,Android Studio,Cursor,java.lang.SecurityException:权限拒绝:从ProcessRecord{6f31548 13761:com.spotbros.enterprise/u0a88}(pid=13761,uid=10088)打开提供程序com.android.providers.media.MediaDocuments提供程序需要使用操作\打开\文档或相关API获得访问权限 这是我捕获异常的代码: if (scheme.equals("content")) { Cursor c

java.lang.SecurityException:权限拒绝:从ProcessRecord{6f31548 13761:com.spotbros.enterprise/u0a88}(pid=13761,uid=10088)打开提供程序com.android.providers.media.MediaDocuments提供程序需要使用操作\打开\文档或相关API获得访问权限

这是我捕获异常的代码:

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();
            }
        }
    }