TeamAmaze / TeamAmaze/AmazeFileManager
Unable to move a file between 2 removables storage
@TranceLove is already working on this.
Since Mar 31, 2018.
- Dominant language
- Kotlin
- Stars
- 6.4k
- Forks
- 1.7k
- Avg merge
- 3d 9h
- Merged PRs (30d)
- 1
Description
Hi,
Whenever you want to write to an external storage (removable usb or external sdcard) we must have access granted via the internal file provider?
In this case it is impossible to cut / paste a file between 2 removables storage.
I added this in MainActivity's onCreate () to check uris granted:
(minSdkVersion 19 in gradle)
List<UriPermission> permissionList = getContentResolver().getPersistedUriPermissions();
for (UriPermission perm : permissionList){
Log.i("perm",perm.getUri().toString());
}
result output:
I/perm: content://com.android.externalstorage.documents/tree/C853-72E5%3A
I/perm: content://com.android.externalstorage.documents/tree/44F4-DBD5%3A
I/perm: content://com.android.externalstorage.documents/tree/8A26-6180%3A
The uris of my three storages are persistent granted and registered in PreferencesConstants.PREFERENCE_URI:
....
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) getPrefs().edit().putString(PreferencesConstants.PREFERENCE_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);
}
....
I did not find in the code where are handle checking preferences to check if the destination uri is ok.
NB: it seems that solidExplorer offers this possibility of persistence of all the uris granted
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.