Example usage for android.content Intent FLAG_GRANT_WRITE_URI_PERMISSION

List of usage examples for android.content Intent FLAG_GRANT_WRITE_URI_PERMISSION

Introduction

In this page you can find the example usage for android.content Intent FLAG_GRANT_WRITE_URI_PERMISSION.

Prototype

int FLAG_GRANT_WRITE_URI_PERMISSION

To view the source code for android.content Intent FLAG_GRANT_WRITE_URI_PERMISSION.

Click Source Link

Document

If set, the recipient of this Intent will be granted permission to perform write operations on the URI in the Intent's data and any URIs specified in its ClipData.

Usage

From source file:cn.edu.wyu.documentviewer.DocumentsActivity.java

private void onFinished(Uri... uris) {
    Log.d(TAG, "onFinished() " + Arrays.toString(uris));

    final Intent intent = new Intent();
    if (uris.length == 1) {
        intent.setData(uris[0]);//from w w  w  .  j a v a 2  s . c  o m
    } else if (uris.length > 1) {
        final ClipData clipData = new ClipData(null, mState.acceptMimes, new ClipData.Item(uris[0]));
        for (int i = 1; i < uris.length; i++) {
            clipData.addItem(new ClipData.Item(uris[i]));
        }
        intent.setClipData(clipData);
    }

    if (mState.action == ACTION_GET_CONTENT) {
        intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    } else {
        intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION
                | Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
    }

    setResult(Activity.RESULT_OK, intent);
    finish();
}

From source file:org.de.jmg.learn.MainActivity.java

@SuppressLint("NewApi")
private void takePersistableUri(Uri selectedUri, boolean force) throws Exception {
    if (Build.VERSION.SDK_INT >= 19) {
        try {/*from w ww  .j  a  v  a  2 s .c  o m*/
            final int takeFlags = (Intent.FLAG_GRANT_READ_URI_PERMISSION
                    | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
            // Check for the freshest data.
            getContentResolver().takePersistableUriPermission(selectedUri, takeFlags);
        } catch (Exception ex) {
            Log.e("takePersistableUri", "Error", ex);
            if (force)
                lib.ShowException(this, ex);
        }

    }
}

From source file:dev.dworks.apps.anexplorer.DocumentsActivity.java

private void onFinished(Uri... uris) {
    Log.d(TAG, "onFinished() " + Arrays.toString(uris));

    final Intent intent = new Intent();
    if (uris.length == 1) {
        intent.setData(uris[0]);//ww  w  .  java 2 s  .  c o  m
    } else if (uris.length > 1) {
        final ClipData clipData = new ClipData(null, mState.acceptMimes, new ClipData.Item(uris[0]));
        for (int i = 1; i < uris.length; i++) {
            clipData.addItem(new ClipData.Item(uris[i]));
        }
        if (Utils.hasJellyBean()) {
            intent.setClipData(clipData);
        } else {
            intent.setData(uris[0]);
        }
    }

    if (mState.action == ACTION_GET_CONTENT || mState.action == ACTION_BROWSE) {
        intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    } else {
        intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
    }

    setResult(Activity.RESULT_OK, intent);
    finish();
}

From source file:org.appspot.apprtc.CallActivity.java

protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
    if (requestCode == FILE_CODE && resultCode == Activity.RESULT_OK) {
        Uri path = intent.getData();//from  ww  w.  j  a  v a 2  s.c  o m
        long size = 0;
        String name = "";
        ContentResolver cr = this.getContentResolver();
        String mime = cr.getType(path);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            size = TokenPeerConnection.getContentSize(path, this);
            name = TokenPeerConnection.getContentName(path, this);

            final int takeFlags = intent.getFlags()
                    & (Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
            // Check for the freshest data.
            getContentResolver().takePersistableUriPermission(path,
                    Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
        } else {
            size = TokenPeerConnection.getContentSize(path, this);
            name = TokenPeerConnection.getContentName(path, this);
        }

        // Do something with the result...
        if (mService != null) {
            SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
            fmt.setTimeZone(TimeZone.getTimeZone("GMT"));
            String time = fmt.format(new Date());
            FileInfo fileInfo = new FileInfo("", "", name, String.valueOf(size), mime);
            mService.sendFileMessage(time, mService.getAccountName(), "self", fileInfo, path.toString(), size,
                    name, mime, mFileRecipient, mService.getCurrentRoomName());

            ChatItem item = new ChatItem(time, mService.getAccountName(), fileInfo, "self", mFileRecipient);
            item.setOutgoing();

            chatFragment.addOutgoingMessage(item);
        }

    }
}

From source file:com.xperia64.timidityae.TimidityActivity.java

@SuppressLint("NewApi")
@Override//from  w w w .  j a v  a2s .c om
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // Check which request we're responding to
    if (requestCode == 1) {
        if (oldTheme != Globals.theme) {
            Intent intent = getIntent();
            intent.putExtra("justtheme", true);
            intent.putExtra("needservice", false);
            finish();
            startActivity(intent);
        }

    } else if (requestCode == 42) {
        if (resultCode == RESULT_OK) {
            Uri treeUri = data.getData();
            getContentResolver().takePersistableUriPermission(treeUri,
                    Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
        }
        initCallback2();
    }
}

From source file:com.free.searcher.MainFragment.java

/**
 * After triggering the Storage Access Framework, ensure that folder is really writable. Set preferences
 * accordingly.//from w ww. j a va 2s.  c  o  m
 *
 * @param requestCode The integer request code originally supplied to startActivityForResult(), allowing you to identify who
 *                    this result came from.
 * @param resultCode  The integer result code returned by the child activity through its setResult().
 * @param data        An Intent, which can return result data to the caller (various data can be attached to Intent
 *                    "extras").
 */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void onActivityResultLollipop(final int requestCode, final int resultCode, @NonNull final Intent data) {

    if (requestCode == INTENT_WRITE_REQUEST_CODE) {

        if (resultCode == Activity.RESULT_OK) {
            // Get Uri from Storage Access Framework. 
            Uri treeUri = data.getData();
            // Persist URI in shared preference so that you can use it later. 
            // Use your own framework here instead of PreferenceUtil. 

            FileUtils.setSharedPreferenceUri(R.string.key_internal_uri_extsdcard, treeUri);
            // Persist access permissions. 
            final int takeFlags = data.getFlags()
                    & (Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
            System.out.println("treeUri:" + treeUri);
            System.out.println("takeFlags" + String.valueOf(takeFlags));
            System.out.println("data.getFlags()" + String.valueOf(data.getFlags()));
            activity.getContentResolver().takePersistableUriPermission(treeUri, takeFlags);
        }
    }

}

From source file:com.amaze.filemanager.activities.MainActivity.java

protected void onActivityResult(int requestCode, int responseCode, Intent intent) {
    if (requestCode == RC_SIGN_IN && !mGoogleApiKey && mGoogleApiClient != null) {
        new Thread(new Runnable() {
            @Override/*ww  w  . java 2  s.c  o m*/
            public void run() {
                mIntentInProgress = false;
                mGoogleApiKey = true;
                // !mGoogleApiClient.isConnecting
                if (mGoogleApiClient.isConnecting()) {
                    mGoogleApiClient.connect();
                } else
                    mGoogleApiClient.disconnect();

            }
        }).run();
    } else if (requestCode == image_selector_request_code) {
        if (Sp != null && intent != null && intent.getData() != null) {
            if (Build.VERSION.SDK_INT >= 19)
                getContentResolver().takePersistableUriPermission(intent.getData(),
                        Intent.FLAG_GRANT_READ_URI_PERMISSION);
            Sp.edit().putString("drawer_header_path", intent.getData().toString()).commit();
            setDrawerHeaderBackground();
        }
    } else if (requestCode == 3) {
        String p = Sp.getString("URI", null);
        Uri oldUri = null;
        if (p != null)
            oldUri = Uri.parse(p);
        Uri treeUri = null;
        if (responseCode == Activity.RESULT_OK) {
            // Get Uri from Storage Access Framework.
            treeUri = intent.getData();
            // Persist URI - this is required for verification of writability.
            if (treeUri != null)
                Sp.edit().putString("URI", treeUri.toString()).commit();
        }
        // If not confirmed SAF, or if still not writable, then revert settings.
        if (responseCode != Activity.RESULT_OK) {
            /* DialogUtil.displayError(getActivity(), R.string.message_dialog_cannot_write_to_folder_saf, false,
                currentFolder);||!FileUtil.isWritableNormalOrSaf(currentFolder)
            */
            if (treeUri != null)
                Sp.edit().putString("URI", oldUri.toString()).commit();
            return;
        }

        // After confirmation, update stored value of folder.
        // Persist access permissions.
        final int takeFlags = intent.getFlags()
                & (Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
        getContentResolver().takePersistableUriPermission(treeUri, takeFlags);
        switch (operation) {
        case DataUtils.DELETE://deletion
            new DeleteTask(null, mainActivity).execute((oparrayList));
            break;
        case DataUtils.COPY://copying
            Intent intent1 = new Intent(con, CopyService.class);
            intent1.putExtra("FILE_PATHS", (oparrayList));
            intent1.putExtra("COPY_DIRECTORY", oppathe);
            startService(intent1);
            break;
        case DataUtils.MOVE://moving
            new MoveFiles((oparrayList), ((Main) getFragment().getTab()),
                    ((Main) getFragment().getTab()).getActivity(), 0)
                            .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, path);
            break;
        case DataUtils.NEW_FOLDER://mkdir
            Main ma1 = ((Main) getFragment().getTab());
            mainActivityHelper.mkDir(RootHelper.generateBaseFile(new File(oppathe), true), ma1);
            break;
        case DataUtils.RENAME:
            mainActivityHelper.rename(HFile.LOCAL_MODE, (oppathe), (oppathe1), mainActivity, rootmode);
            Main ma2 = ((Main) getFragment().getTab());
            ma2.updateList();
            break;
        case DataUtils.NEW_FILE:
            Main ma3 = ((Main) getFragment().getTab());
            mainActivityHelper.mkFile(new HFile(HFile.LOCAL_MODE, oppathe), ma3);

            break;
        case DataUtils.EXTRACT:
            mainActivityHelper.extractFile(new File(oppathe));
            break;
        case DataUtils.COMPRESS:
            mainActivityHelper.compressFiles(new File(oppathe), oparrayList);
        }
        operation = -1;
    }
}

From source file:com.filemanager.free.activities.MainActivity.java

protected void onActivityResult(int requestCode, int responseCode, Intent intent) {
    if (requestCode == RC_SIGN_IN && !mGoogleApiKey && mGoogleApiClient != null) {
        new Thread(new Runnable() {
            @Override/*from  w ww.java  2  s .c  om*/
            public void run() {
                mIntentInProgress = false;
                mGoogleApiKey = true;
                // !mGoogleApiClient.isConnecting
                if (mGoogleApiClient.isConnecting()) {
                    mGoogleApiClient.connect();
                } else
                    mGoogleApiClient.disconnect();

            }
        }).run();
    } else if (requestCode == image_selector_request_code) {
        if (Sp != null && intent != null && intent.getData() != null) {
            if (Build.VERSION.SDK_INT >= 19) {
                getContentResolver().takePersistableUriPermission(intent.getData(),
                        Intent.FLAG_GRANT_READ_URI_PERMISSION);
            } else {
                con.getApplicationContext().grantUriPermission(BuildConfig.APPLICATION_ID, intent.getData(),
                        Intent.FLAG_GRANT_READ_URI_PERMISSION);
            }

            Sp.edit().putString("drawer_header_path", intent.getData().toString()).commit();
            setDrawerHeaderBackground();
        }
    } else if (requestCode == 3) {
        String p = Sp.getString("URI", null);
        Uri oldUri = null;
        if (p != null)
            oldUri = Uri.parse(p);
        Uri treeUri = null;
        if (responseCode == Activity.RESULT_OK) {
            // Get Uri from Storage Access Framework.
            treeUri = intent.getData();
            // Persist URI - this is required for verification of writability.
            if (treeUri != null) {
                Sp.edit().putString("URI", treeUri.toString()).commit();
            }
        }
        // If not confirmed SAF, or if still not writable, then revert settings.
        if (responseCode != Activity.RESULT_OK) {
            /* DialogUtil.displayError(getActivity(), R.string.message_dialog_cannot_write_to_folder_saf, false,
                currentFolder);||!FileUtil.isWritableNormalOrSaf(currentFolder)
            */
            if (treeUri != null) {
                Sp.edit().putString("URI", oldUri.toString()).commit();
            }
            return;
        }

        // After confirmation, update stored value of folder.
        // Persist access permissions.
        int takeFlags = intent.getFlags();
        takeFlags &= (Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            if (treeUri != null) {
                getContentResolver().takePersistableUriPermission(treeUri, takeFlags);
            }
        } else {
            if (treeUri != null) {
                con.getApplicationContext().grantUriPermission(BuildConfig.APPLICATION_ID, treeUri, takeFlags);
            }
        }
        switch (operation) {
        case DataUtils.DELETE://deletion
            new DeleteTask(null, mainActivity).execute((oparrayList));
            break;
        case DataUtils.COPY://copying
            Intent intent1 = new Intent(con, CopyService.class);
            intent1.putExtra("FILE_PATHS", (oparrayList));
            intent1.putExtra("COPY_DIRECTORY", oppathe);
            startService(intent1);
            break;
        case DataUtils.MOVE://moving
            new MoveFiles((oparrayList), ((Main) getFragment().getTab()),
                    ((Main) getFragment().getTab()).getActivity(), 0)
                            .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, path);
            break;
        case DataUtils.NEW_FOLDER://mkdir
            Main ma1 = ((Main) getFragment().getTab());
            mainActivityHelper.mkDir(RootHelper.generateBaseFile(new File(oppathe), true), ma1);
            break;
        case DataUtils.RENAME:
            mainActivityHelper.rename(HFile.LOCAL_MODE, (oppathe), (oppathe1), mainActivity, rootmode);
            Main ma2 = ((Main) getFragment().getTab());
            ma2.updateList();
            break;
        case DataUtils.NEW_FILE:
            Main ma3 = ((Main) getFragment().getTab());
            mainActivityHelper.mkFile(new HFile(HFile.LOCAL_MODE, oppathe), ma3);

            break;
        case DataUtils.EXTRACT:
            mainActivityHelper.extractFile(new File(oppathe));
            break;
        case DataUtils.COMPRESS:
            mainActivityHelper.compressFiles(new File(oppathe), oparrayList);
        }
        operation = -1;
    }
}

From source file:com.igniva.filemanager.activities.MainActivity.java

protected void onActivityResult(int requestCode, int responseCode, Intent intent) {
    if (requestCode == RC_SIGN_IN && !mGoogleApiKey && mGoogleApiClient != null) {
        new Thread(new Runnable() {
            @Override//from w w  w  . j a v a 2  s  . c  om
            public void run() {
                mIntentInProgress = false;
                mGoogleApiKey = true;
                // !mGoogleApiClient.isConnecting
                if (mGoogleApiClient.isConnecting()) {
                    mGoogleApiClient.connect();
                } else
                    mGoogleApiClient.disconnect();

            }
        }).run();
    } else if (requestCode == image_selector_request_code) {
        if (Sp != null && intent != null && intent.getData() != null) {
            if (Build.VERSION.SDK_INT >= 19)
                getContentResolver().takePersistableUriPermission(intent.getData(),
                        Intent.FLAG_GRANT_READ_URI_PERMISSION);
            Sp.edit().putString("drawer_header_path", intent.getData().toString()).commit();
            setDrawerHeaderBackground();
        }
    } else if (requestCode == 3) {
        String p = Sp.getString("URI", null);

        Uri oldUri = p != null ? Uri.parse(p) : null;
        Uri treeUri = null;
        if (responseCode == Activity.RESULT_OK) {
            // Get Uri from Storage Access Framework.
            treeUri = intent.getData();
            // Persist URI - this is required for verification of writability.
            if (treeUri != null)
                Sp.edit().putString("URI", treeUri.toString()).commit();
        }
        // If not confirmed SAF, or if still not writable, then revert settings.
        if (responseCode != Activity.RESULT_OK) {
            /* DialogUtil.displayError(getActivity(), R.string.message_dialog_cannot_write_to_folder_saf, false,
                currentFolder);||!FileUtil.isWritableNormalOrSaf(currentFolder)
            */
            if (treeUri != null)
                Sp.edit().putString("URI", oldUri.toString()).commit();
            return;
        }

        // After confirmation, update stored value of folder.
        // Persist access permissions.
        final int takeFlags = intent.getFlags()
                & (Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
        getContentResolver().takePersistableUriPermission(treeUri, takeFlags);
        switch (operation) {
        case DataUtils.DELETE://deletion
            new DeleteTask(null, mainActivity).execute((oparrayList));
            break;
        case DataUtils.COPY://copying
            Intent intent1 = new Intent(con, CopyService.class);
            intent1.putExtra("FILE_PATHS", (oparrayList));
            intent1.putExtra("COPY_DIRECTORY", oppathe);
            startService(intent1);
            break;
        case DataUtils.MOVE://moving
            new MoveFiles((oparrayList), ((Main) getFragment().getTab()),
                    ((Main) getFragment().getTab()).getActivity(), 0)
                            .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, path);
            break;
        case DataUtils.NEW_FOLDER://mkdir
            Main ma1 = ((Main) getFragment().getTab());
            mainActivityHelper.mkDir(RootHelper.generateBaseFile(new File(oppathe), true), ma1);
            break;
        case DataUtils.RENAME:
            mainActivityHelper.rename(HFile.LOCAL_MODE, (oppathe), (oppathe1), mainActivity,
                    BaseActivity.rootMode);
            Main ma2 = ((Main) getFragment().getTab());
            ma2.updateList();
            break;
        case DataUtils.NEW_FILE:
            Main ma3 = ((Main) getFragment().getTab());
            mainActivityHelper.mkFile(new HFile(HFile.LOCAL_MODE, oppathe), ma3);

            break;
        case DataUtils.EXTRACT:
            mainActivityHelper.extractFile(new File(oppathe));
            break;
        case DataUtils.COMPRESS:
            mainActivityHelper.compressFiles(new File(oppathe), oparrayList);
        }
        operation = -1;
    }
}

From source file:com.amaze.carbonfilemanager.activities.MainActivity.java

protected void onActivityResult(int requestCode, int responseCode, Intent intent) {
    if (requestCode == RC_SIGN_IN && !mGoogleApiKey && mGoogleApiClient != null) {
        new Thread(new Runnable() {
            @Override/*from ww  w .  j  ava 2  s .c  om*/
            public void run() {
                mIntentInProgress = false;
                mGoogleApiKey = true;
                // !mGoogleApiClient.isConnecting
                if (mGoogleApiClient.isConnecting()) {
                    mGoogleApiClient.connect();
                } else
                    mGoogleApiClient.disconnect();

            }
        }).run();
    } else if (requestCode == image_selector_request_code) {
        if (sharedPref != null && intent != null && intent.getData() != null) {
            if (SDK_INT >= 19)
                getContentResolver().takePersistableUriPermission(intent.getData(),
                        Intent.FLAG_GRANT_READ_URI_PERMISSION);
            sharedPref.edit().putString("drawer_header_path", intent.getData().toString()).commit();
            setDrawerHeaderBackground();
        }
    } else if (requestCode == 3) {
        Uri treeUri;
        if (responseCode == Activity.RESULT_OK) {
            // Get Uri from Storage Access Framework.
            treeUri = intent.getData();
            // Persist URI - this is required for verification of writability.
            if (treeUri != null)
                sharedPref.edit().putString("URI", treeUri.toString()).commit();
        } else {
            // If not confirmed SAF, or if still not writable, then revert settings.
            /* DialogUtil.displayError(getActivity(), R.string.message_dialog_cannot_write_to_folder_saf, false, currentFolder);
                ||!FileUtil.isWritableNormalOrSaf(currentFolder)*/
            return;
        }

        // After confirmation, update stored value of folder.
        // Persist access permissions.

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            getContentResolver().takePersistableUriPermission(treeUri,
                    Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
        }
        switch (operation) {
        case DataUtils.DELETE://deletion
            new DeleteTask(null, mainActivity).execute((oparrayList));
            break;
        case DataUtils.COPY://copying
            //legacy compatibility
            if (oparrayList != null && oparrayList.size() != 0) {
                oparrayListList = new ArrayList<>();
                oparrayListList.add(oparrayList);
                oparrayList = null;
                oppatheList = new ArrayList<>();
                oppatheList.add(oppathe);
                oppathe = "";
            }
            for (int i = 0; i < oparrayListList.size(); i++) {
                Intent intent1 = new Intent(con, CopyService.class);
                intent1.putExtra(CopyService.TAG_COPY_SOURCES, oparrayList.get(i));
                intent1.putExtra(CopyService.TAG_COPY_TARGET, oppatheList.get(i));
                ServiceWatcherUtil.runService(this, intent1);
            }
            break;
        case DataUtils.MOVE://moving
            //legacy compatibility
            if (oparrayList != null && oparrayList.size() != 0) {
                oparrayListList = new ArrayList<>();
                oparrayListList.add(oparrayList);
                oparrayList = null;
                oppatheList = new ArrayList<>();
                oppatheList.add(oppathe);
                oppathe = "";
            }

            new MoveFiles(oparrayListList, ((MainFragment) getFragment().getTab()),
                    getFragment().getTab().getActivity(), OpenMode.FILE)
                            .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, oppatheList);
            break;
        case DataUtils.NEW_FOLDER://mkdir
            MainFragment ma1 = ((MainFragment) getFragment().getTab());
            mainActivityHelper.mkDir(RootHelper.generateBaseFile(new File(oppathe), true), ma1);
            break;
        case DataUtils.RENAME:
            MainFragment ma2 = ((MainFragment) getFragment().getTab());
            mainActivityHelper.rename(ma2.openMode, (oppathe), (oppathe1), mainActivity, BaseActivity.rootMode);
            ma2.updateList();
            break;
        case DataUtils.NEW_FILE:
            MainFragment ma3 = ((MainFragment) getFragment().getTab());
            mainActivityHelper.mkFile(new HFile(OpenMode.FILE, oppathe), ma3);

            break;
        case DataUtils.EXTRACT:
            mainActivityHelper.extractFile(new File(oppathe));
            break;
        case DataUtils.COMPRESS:
            mainActivityHelper.compressFiles(new File(oppathe), oparrayList);
        }
        operation = -1;
    } else if (requestCode == REQUEST_CODE_SAF && responseCode == Activity.RESULT_OK) {
        // otg access
        sharedPref.edit().putString(KEY_PREF_OTG, intent.getData().toString()).apply();

        if (!isDrawerLocked)
            mDrawerLayout.closeDrawer(mDrawerLinear);
        else
            onDrawerClosed();
    } else if (requestCode == REQUEST_CODE_SAF && responseCode != Activity.RESULT_OK) {
        // otg access not provided
        pendingPath = null;
    }
}