List of usage examples for android.content Intent ACTION_OPEN_DOCUMENT_TREE
String ACTION_OPEN_DOCUMENT_TREE
To view the source code for android.content Intent ACTION_OPEN_DOCUMENT_TREE.
Click Source Link
From source file:com.almalence.opencam.Fragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); thiz = this;//from w w w . j a va2 s . c o m String settings = getArguments().getString("type"); ApplicationScreen.getPluginManager().loadHeaderContent(settings, this); if (null == getPreferenceScreen()) return; for (int i = 0; i < getPreferenceScreen().getPreferenceCount(); i++) { initSummary(getPreferenceScreen().getPreference(i)); } Preference nightPreference = findPreference("night"); if (nightPreference != null) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); if (prefs.getBoolean("useCamera2Pref", false)) { getPreferenceScreen().removePreference(nightPreference); } else { Preference superPreference = findPreference("super"); getPreferenceScreen().removePreference(superPreference); } } final SeekBarPreference brightnessPref = (SeekBarPreference) this.findPreference("brightnessPref"); if (brightnessPref != null) { // Set seekbar summary : float gamma = PreferenceManager.getDefaultSharedPreferences(getActivity()).getFloat("gammaPref", 0.5f); brightnessPref.setSummary( this.getString(R.string.Pref_Super_BrightnessEnhancementValue).replace("$1", "" + gamma)); brightnessPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { private final Map<Integer, Float> gamma_map = new HashMap<Integer, Float>() { { put(0, 0.5f); put(1, 0.55f); put(2, 0.6f); put(3, 0.65f); put(4, 0.7f); } }; @Override public boolean onPreferenceChange(Preference preference, Object newValue) { int radius = (Integer) newValue; float gamma = gamma_map.get(radius); PreferenceManager .getDefaultSharedPreferences(Fragment.thiz.getActivity().getApplicationContext()).edit() .putFloat("gammaPref", gamma).commit(); brightnessPref.setSummary(getActivity() .getString(R.string.Pref_Super_BrightnessEnhancementValue).replace("$1", "" + gamma)); return true; } }); } final CheckBoxPreference upscalePref = (CheckBoxPreference) this.findPreference("upscaleResult"); if (upscalePref != null) { Size size = CameraController.getMaxCameraImageSize(CameraController.YUV); long resMpx = 0; float mpix = 0.0f; if (size != null) { resMpx = (long) ((long) size.getWidth() * (long) size.getHeight() * 2.25); mpix = (float) resMpx / 1000000.f; } String name = String.format("%3.1f Mpix ", mpix); upscalePref.setSummary( getActivity().getString(R.string.Pref_Super_SummaryUpscale).replace("$1", "" + name)); } Preference cameraParameters = findPreference("camera_parameters"); if (cameraParameters != null) { cameraParameters.setOnPreferenceClickListener(new OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { try { showCameraParameters(); } catch (Exception e) { e.printStackTrace(); } return true; } }); } CheckBoxPreference helpPref = (CheckBoxPreference) findPreference("showHelpPrefCommon"); if (helpPref != null) helpPref.setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { if (((CheckBoxPreference) preference).isChecked()) { SharedPreferences prefs = PreferenceManager .getDefaultSharedPreferences(MainScreen.getMainContext()); Editor prefsEditor = prefs.edit(); prefsEditor.putBoolean("droShowHelp", true); prefsEditor.putBoolean("sequenceRemovalShowHelp", true); prefsEditor.putBoolean("panoramaShowHelp", true); prefsEditor.putBoolean("superShowHelp", true); prefsEditor.putBoolean("groupshotRemovalShowHelp", true); prefsEditor.putBoolean("objectRemovalShowHelp", true); prefsEditor.putBoolean("bestShotShowHelp", true); prefsEditor.commit(); } return true; } }); EditTextPreference prefix = (EditTextPreference) this .findPreference(getResources().getString(R.string.Preference_SavePathPrefixValue)); EditTextPreference postfix = (EditTextPreference) this .findPreference(getResources().getString(R.string.Preference_SavePathPostfixValue)); initExportName(null, null); if (prefix != null) { prefix.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { initExportName(preference, newValue); return true; } }); } if (postfix != null) { postfix.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { initExportName(preference, newValue); return true; } }); } Preference sonyPreference = findPreference(MainScreen.sSonyCamerasPref); if (sonyPreference != null) { sonyPreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { boolean sonyCamerasAvailable = (Boolean) newValue; if (sonyCamerasAvailable) { Toast.makeText(getActivity(), getActivity().getString(R.string.pref_general_more_sonyCamera_available), Toast.LENGTH_SHORT).show(); } return true; } }); } ListPreference saveToPreference = (ListPreference) this .findPreference(getResources().getString(R.string.Preference_SaveToValue)); // if android 5+, then remove "save to SD card" option. Because it's // equals to "save to custom folder" option. if (saveToPreference != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { CharSequence[] entries = saveToPreference.getEntries(); CharSequence[] entriyValues = saveToPreference.getEntryValues(); CharSequence[] newEntries = new String[2]; CharSequence[] newEntriyValues = new String[2]; newEntries[0] = entries[0]; newEntries[1] = entries[2]; newEntriyValues[0] = entriyValues[0]; newEntriyValues[1] = entriyValues[2]; saveToPreference.setEntries(newEntries); saveToPreference.setEntryValues(newEntriyValues); } if (saveToPreference != null) { saveToPreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { int v = -1; int v_old = 0; try { v = Integer.parseInt(newValue.toString()); v_old = Integer.parseInt(((ListPreference) preference).getValue()); } catch (NumberFormatException e) { } if ((v == 2 || v == 1) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { Toast.makeText(MainScreen.getInstance(), MainScreen.getAppResources() .getString(R.string.pref_advanced_saving_saveToPref_CantSaveToSD), Toast.LENGTH_LONG).show(); if (isDeviceRooted()) { Intent intent = new Intent(Preferences.thiz, FolderPicker.class); intent.putExtra(MainScreen.sSavePathPref, v_old); Preferences.thiz.startActivity(intent); return true; } else return false; } } if (v == 2 || v == 1) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); startActivityForResult(intent, CHOOSE_FOLDER_CODE); } else if (v != 1) { Intent intent = new Intent(Preferences.thiz, FolderPicker.class); intent.putExtra(MainScreen.sSavePathPref, v_old); Preferences.thiz.startActivity(intent); } } return true; } }); } PreferenceCategory cat = (PreferenceCategory) this.findPreference("Pref_VFCommon_Preference_Category"); if (cat != null) { CheckBoxPreference cp = (CheckBoxPreference) cat.findPreference("maxScreenBrightnessPref"); if (cp != null) { cp.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { boolean value = Boolean.parseBoolean(newValue.toString()); setScreenBrightness(value); return true; } }); } } SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this.getActivity()); boolean MaxScreenBrightnessPreference = prefs.getBoolean("maxScreenBrightnessPref", false); setScreenBrightness(MaxScreenBrightnessPreference); }
From source file:com.osama.cryptofm.filemanager.ui.FilemanagerTabs.java
private void getExternalStoragePermissions() { Log.d(TAG, "getExternalStoragePermissions: Getting permissions"); //inform user what to do final AlertDialog.Builder dialog = new AlertDialog.Builder(this); dialog.setCancelable(false);/*from w w w . ja va 2 s . com*/ dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); startActivityForResult(intent, GET_PERMISSION_CODE); } }); dialog.setMessage("Looks like you have external sdcard. " + "Please choose it in next screen to enable read and write on it. " + "Otherwise I will not be able to use it"); dialog.setNegativeButton("No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { mStorageTitles[0] = mStorageTitles[1]; Toast.makeText(FilemanagerTabs.this, "I wont be able to perform any operation on external sdcard", Toast.LENGTH_LONG).show(); } }); dialog.setTitle("Need permission"); dialog.show(); }
From source file:ml.puredark.hviewer.ui.fragments.SettingFragment.java
@Override public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { if (preference.getKey().equals(KEY_PREF_ABOUT_UPGRADE)) { ////from ww w .j av a 2s.c o m if (!checking) UpdateManager.checkUpdate(activity); } else if (preference.getKey().equals(KEY_PREF_BKRS_BACKUP)) { // new AlertDialog.Builder(activity).setTitle("?").setMessage("?") .setPositiveButton(getString(R.string.ok), (dialog, which) -> { String backup = new DataBackup().DoBackup(); activity.showSnackBar(backup); }).setNegativeButton(getString(R.string.cancel), null).show(); } else if (preference.getKey().equals(KEY_PREF_BKRS_RESTORE)) { // new AlertDialog.Builder(activity).setTitle("???") .setMessage("????") .setPositiveButton(getString(R.string.ok), (dialog, which) -> { String restore = new DataRestore().DoRestore(); Intent intent = new Intent(); activity.setResult(RESULT_OK, intent); Toast.makeText(activity, restore, Toast.LENGTH_LONG).show(); activity.finish(); }).setNegativeButton(getString(R.string.cancel), null).show(); } else if (preference.getKey().equals(KEY_PREF_ABOUT_LICENSE)) { //??? Intent intent = new Intent(activity, LicenseActivity.class); startActivity(intent); } else if (preference.getKey().equals(KEY_PREF_ABOUT_PRIVACY)) { //??? Intent intent = new Intent(activity, PrivacyActivity.class); startActivity(intent); } else if (preference.getKey().equals(KEY_PREF_ABOUT_H_VIEWER)) { // FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.replace(R.id.setting_content, new AboutFragment(activity)); transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); transaction.addToBackStack(null); transaction.commit(); } else if (preference.getKey().equals(KEY_PREF_DOWNLOAD_PATH)) { // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION); try { startActivityForResult(intent, RESULT_CHOOSE_DIRECTORY); } catch (ActivityNotFoundException e) { e.printStackTrace(); mDialog.show(getFragmentManager(), null); } new Handler().postDelayed(() -> { if (!opened) activity.showSnackBar("?"); }, 1000); } else { mDialog.show(getFragmentManager(), null); } } else if (preference.getKey().equals(KEY_PREF_DOWNLOAD_IMPORT)) { // new AlertDialog.Builder(activity).setTitle("?") .setMessage("??") .setPositiveButton(getString(R.string.ok), (dialog, which) -> { DownloadedImport(); }).setNegativeButton(getString(R.string.cancel), null).show(); } else if (preference.getKey().equals(KEY_PREF_FAVOURITE_EXPORT)) { //? new AlertDialog.Builder(activity).setTitle("??") .setMessage("?") .setPositiveButton("", (dialog, which) -> { DocumentFile file = FileHelper.createFileIfNotExist(Names.favouritesname, DownloadManager.getDownloadPath(), Names.backupdirname); if (file != null) { FavouriteHolder holder = new FavouriteHolder(activity); String json = new Gson().toJson(holder.getFavourites()); FileHelper.writeString(json, file); holder.onDestroy(); activity.showSnackBar("??"); } else activity.showSnackBar(""); }).setNegativeButton(getString(R.string.cancel), null).show(); } else if (preference.getKey().equals(KEY_PREF_FAVOURITE_IMPORT)) { //? new AlertDialog.Builder(activity).setTitle("??") .setMessage("???") .setPositiveButton(getString(R.string.ok), (dialog, which) -> { String json = FileHelper.readString(Names.favouritesname, DownloadManager.getDownloadPath(), Names.backupdirname); if (json == null) { activity.showSnackBar("?"); } else { try { List<Pair<CollectionGroup, List<LocalCollection>>> favGroups = new Gson().fromJson( json, new TypeToken<ArrayList<Pair<CollectionGroup, ArrayList<LocalCollection>>>>() { }.getType()); FavouriteHolder holder = new FavouriteHolder(activity); for (Pair<CollectionGroup, List<LocalCollection>> pair : favGroups) { Logger.d("DataStore", "" + pair.first); CollectionGroup group = holder.getGroupByTitle(pair.first.title); if (group == null) { group = pair.first; group.gid = holder.addFavGroup(group); } for (LocalCollection collection : pair.second) { collection.gid = group.gid; holder.addFavourite(collection); } } holder.onDestroy(); activity.showSnackBar("??"); } catch (Exception e) { e.printStackTrace(); activity.showSnackBar("?"); } } }).setNegativeButton(getString(R.string.cancel), null).show(); } else if (preference.getKey().equals(KEY_PREF_CACHE_CLEAN)) { // new AlertDialog.Builder(activity).setTitle("?") .setMessage("??") .setPositiveButton(getString(R.string.ok), (dialog, which) -> { ImagePipeline imagePipeline = Fresco.getImagePipeline(); imagePipeline.clearDiskCaches(); activity.showSnackBar("??"); preference.setSummary(" 0.00 MB"); }).setNegativeButton(getString(R.string.cancel), null).show(); } else if (preference.getKey().equals(KEY_PREF_PROXY_DETAIL)) { //PROXY? FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.replace(R.id.setting_content, new ProxyFragment(activity)); transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); transaction.addToBackStack(null); transaction.commit(); } else if (preference.getKey().equals(KEY_PREF_LOCK_METHODS_DETAIL)) { //?? FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.replace(R.id.setting_content, new LockMethodFragment(activity)); transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); transaction.addToBackStack(null); transaction.commit(); } return super.onPreferenceTreeClick(preferenceScreen, preference); }
From source file:com.farmerbb.notepad.activity.MainActivity.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override//from w ww.j ava 2 s . c o m public void exportNotes() { filesToExport = cab.toArray(); cab.clear(); if (filesToExport.length == 1 || Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { fileBeingExported = 0; reallyExportNotes(); } else { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); try { startActivityForResult(intent, EXPORT_TREE); } catch (ActivityNotFoundException e) { showToast(R.string.error_exporting_notes); } } }
From source file:com.anjalimacwan.MainActivity.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override//w w w .j a v a 2s . co m public void exportNote(Object[] filesToExport) { this.filesToExport = filesToExport; if (filesToExport.length == 1 || Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { fileBeingExported = 0; reallyExportNote(); } else { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); try { startActivityForResult(intent, EXPORT_TREE); } catch (ActivityNotFoundException e) { showToast(R.string.error_exporting_notes); } } }
From source file:com.mb.android.MainActivity.java
@android.webkit.JavascriptInterface @org.xwalk.core.JavascriptInterface/* w w w. j a va 2 s . c o m*/ public void chooseDirectory() { getLogger().Info("begin chooseDirectory"); if (!authorizeStorage(ExternalStoragePermissionRequestCode)) { return; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); startActivityForResult(intent, REQUEST_DIRECTORY_SAF); } else { getLogger().Info("creating intent for FilePickerActivity"); Intent intent = new Intent(this, FilePickerActivity.class); // This works if you defined the intent filter // Intent i = new Intent(Intent.ACTION_GET_CONTENT); // Set these depending on your use case. These are the defaults. intent.putExtra(FilePickerActivity.EXTRA_ALLOW_MULTIPLE, false); intent.putExtra(FilePickerActivity.EXTRA_ALLOW_CREATE_DIR, true); intent.putExtra(FilePickerActivity.EXTRA_MODE, FilePickerActivity.MODE_DIR); // Configure initial directory by specifying a String. // You could specify a String like "/storage/emulated/0/", but that can // dangerous. Always use Android's API calls to get paths to the SD-card or // internal memory. intent.putExtra(FilePickerActivity.EXTRA_START_PATH, Environment.getExternalStorageDirectory().getPath()); getLogger().Info("startActivityForResult for FilePickerActivity"); startActivityForResult(intent, REQUEST_DIRECTORY); } }
From source file:com.amaze.filemanager.ui.views.drawer.Drawer.java
@Override public boolean onNavigationItemSelected(@NonNull MenuItem item) { actionViewStateManager.deselectCurrentActionView(); actionViewStateManager.selectActionView(item); isSomethingSelected = true;/* ww w. java2 s . c o m*/ String title = item.getTitle().toString(); MenuMetadata meta = dataUtils.getDrawerMetadata(item); switch (meta.type) { case MenuMetadata.ITEM_ENTRY: if (dataUtils.containsBooks(new String[] { title, meta.path }) != -1) { FileUtils.checkForPath(mainActivity, meta.path, mainActivity.isRootExplorer()); } if (dataUtils.getAccounts().size() > 0 && (meta.path.startsWith(CloudHandler.CLOUD_PREFIX_BOX) || meta.path.startsWith(CloudHandler.CLOUD_PREFIX_DROPBOX) || meta.path.startsWith(CloudHandler.CLOUD_PREFIX_ONE_DRIVE) || meta.path.startsWith(CloudHandler.CLOUD_PREFIX_GOOGLE_DRIVE))) { // we have cloud accounts, try see if token is expired or not CloudUtil.checkToken(meta.path, mainActivity); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && meta.path.contains(OTGUtil.PREFIX_OTG) && SingletonUsbOtg.getInstance().getUsbOtgRoot() == null) { MaterialDialog dialog = GeneralDialogCreation.showOtgSafExplanationDialog(mainActivity); dialog.getActionButton(DialogAction.POSITIVE).setOnClickListener((v) -> { SingletonUsbOtg.getInstance().setHasRootBeenRequested(true); Intent safIntent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); mainActivity.startActivityForResult(safIntent, MainActivity.REQUEST_CODE_SAF); dialog.dismiss(); }); dialog.show(); } else { pendingPath = meta.path; closeIfNotLocked(); if (isLocked()) { onDrawerClosed(); } } break; case MenuMetadata.ITEM_INTENT: meta.onClickListener.onClick(); break; } return true; }
From source file:com.xperia64.timidityae.TimidityActivity.java
@SuppressLint("NewApi") public void initCallback() { if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { List<UriPermission> permissions = getContentResolver().getPersistedUriPermissions(); int trueExt = 0; for (File f : getExternalFilesDirs(null)) { if (f != null) trueExt++;//from ww w.j a v a2 s . c om } if ((permissions == null || permissions.isEmpty()) && Globals.shouldLolNag && trueExt > 1) { new AlertDialog.Builder(this).setTitle("SD Card Access").setCancelable(false).setMessage( "Would you like to give Timidity AE write access to your external sd card? This is recommended if you're converting files or would like to place Timidity AE's data directory there. Problems may occur if a directory other than the root of your SD card is selected.") .setPositiveButton("Yes", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); startActivityForResult(intent, 42); } }).setNegativeButton("No, do not ask again", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Globals.prefs.edit().putBoolean("shouldLolNag", Globals.shouldLolNag = false) .commit(); initCallback2(); } }).setNeutralButton("No", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { initCallback2(); } }).show(); } else { for (UriPermission permission : permissions) { if (permission.isReadPermission() && permission.isWritePermission()) { Globals.theFold = permission.getUri(); } } initCallback2(); } } else { initCallback2(); } }
From source file:com.amaze.carbonfilemanager.activities.MainActivity.java
public void selectItem(final int i) { ArrayList<Item> directoryItems = dataUtils.getList(); if (!directoryItems.get(i).isSection()) { if ((selectedStorage == NO_VALUE || selectedStorage >= directoryItems.size())) { TabFragment tabFragment = new TabFragment(); Bundle a = new Bundle(); a.putString("path", ((EntryItem) directoryItems.get(i)).getPath()); tabFragment.setArguments(a); android.support.v4.app.FragmentTransaction transaction = getSupportFragmentManager() .beginTransaction(); transaction.replace(R.id.content_frame, tabFragment); transaction.addToBackStack("tabt1" + 1); pending_fragmentTransaction = transaction; selectedStorage = i;/*w w w. j a va2 s .c om*/ adapter.toggleChecked(selectedStorage); if (!isDrawerLocked) mDrawerLayout.closeDrawer(mDrawerLinear); else onDrawerClosed(); floatingActionButton.setVisibility(View.VISIBLE); floatingActionButton.showMenuButton(true); } else { pendingPath = ((EntryItem) directoryItems.get(i)).getPath(); selectedStorage = i; adapter.toggleChecked(selectedStorage); if (((EntryItem) directoryItems.get(i)).getPath().contains(OTGUtil.PREFIX_OTG) && sharedPref.getString(KEY_PREF_OTG, null).equals(VALUE_PREF_OTG_NULL)) { // we've not gotten otg path yet // start system request for storage access framework Toast.makeText(getApplicationContext(), getString(R.string.otg_access), Toast.LENGTH_LONG) .show(); Intent safIntent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); startActivityForResult(safIntent, REQUEST_CODE_SAF); } else { if (!isDrawerLocked) mDrawerLayout.closeDrawer(mDrawerLinear); else onDrawerClosed(); } } } }
From source file:com.sentaroh.android.SMBExplorer.SMBExplorerMain.java
@SuppressLint("InlinedApi") private void initSafExternalSdcardTreeUri() { if (Build.VERSION.SDK_INT >= 21) { if (SafUtil.hasSafExternalSdcard(mSafCA) && !SafUtil.isValidSafExternalSdcardRootTreeUri(mSafCA)) { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); startActivityForResult(intent, REQUEST_CODE_STORAGE_ACCESS); }//from w w w . j a v a 2 s .c o m // SafFile document=mSafCA.rootDocumentFile; // Log.v("","doc="+document.findFile("LocalBackup")); } }