private void checkSystemDownloadsDirectoryAccess() { if (mDownloadDirectoryOverrideURI != null && !mAlwaysUseFallbackDir) { DocumentFile dir = DocumentFile.fromTreeUri(mContext, mDownloadDirectoryOverrideURI); mHasSystemDirectoryAccess = dir.exists() && dir.canWrite(); return; } File downloadsDir = Environment.getExternalStoragePublicDirectory( Environment.DIRECTORY_DOWNLOADS); if (downloadsDir != null && downloadsDir.canWrite() && !mAlwaysUseFallbackDir) { mDownloadDirectory = downloadsDir; mHasSystemDirectoryAccess = true; } else { mDownloadDirectory = mFallbackDownloadDirectory; mHasSystemDirectoryAccess = false; } Log.d("DCCManager", "Download directory: " + mDownloadDirectory.getAbsolutePath()); }
if (tree.canWrite()) {
if (tree.canWrite()) {
if (tree.canWrite()) {
if (tree.canWrite()) {
public static DocumentFile getDestinationDirectory(Context context) { if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean(PREFERENCE_CUSTOMIZE_DESTINATION, false)) { String path = PreferenceManager.getDefaultSharedPreferences(context).getString(PREFERENCE_DESTINATION, null); if (path != null) { //There should be no way to enter here on api level < kitkat DocumentFile treeDocumentFile = DocumentFile.fromTreeUri(context, Uri.parse(path)); if (treeDocumentFile.canWrite()) { //Checks for FLAG_DIR_SUPPORTS_CREATE on directories return treeDocumentFile; } else { //Maybe permission was revoked Log.w("SharePlugin", "Share destination is not writable, falling back to default path."); } } } try { getDefaultDestinationDirectory().mkdirs(); } catch (Exception e) { e.printStackTrace(); } return DocumentFile.fromFile(getDefaultDestinationDirectory()); }
if (tree.canWrite()) {
if (tree.canWrite()) {