Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CANNOT_CREATE_FILE_IN_TARGET when attempting to save on external drive #106

Open
TortoiseFather opened this issue Dec 10, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@TortoiseFather
Copy link

TortoiseFather commented Dec 10, 2022

Library version: 1.5.1
OS version: [Android 11]
Device model: [Samsung Galaxy A8]

Describe the bug
When invoking DocumentFileUtils.MoveFileTo targeting a folder stored on an external drive (USB SSD in my example) the movement fails.

If the target folder is an internal folder, the move succeeds

Full file permission has been granted, the external folder has been selected using OPEN_DOCUMENT_TREE

To Reproduce

  1. give application full file permissions

  2. select target folder using ACTION_OPEN_DOCUMENT_TREE

  3. select file that will be moved

  4. start background thread

  5. check file can be read and location can be written to

DocumentFileUtils.moveFileTo([any file], this, [Folder on external drive], null, new FileCallBack(){}

Stacktrace
[If applicable]

@anggrayudi
Copy link
Owner

anggrayudi commented Dec 12, 2022

This issue is similar to #8. Adding support for USB mass storage has low priority for now. In the past, I've tried to add it, but I found the complexity is extremely high. So I decided to revert the changes. It will ruin the entire code in the current project, and the regression will be insane. Why? Because:

  1. The USB APIs are poorly designed and not following the SOLID principle. When you use the function in your code, it is compiled successfully, but when executing it will throw java.lang.NoSuchMethodError.
  2. Some required functions are only available as internal/hidden APIs.
  3. The API changes are too frequent, it's hard to maintain the compatibility across the OS versions.
  4. Hard to predict the APIs behavior and their patterns.
  5. Too many rules from the official documentation.
  6. There's no emulator that can simulate the USB. So we are able to test the code on physical devices only. You can see the AVD here only has two options for the storage (internal & SD card):

Screenshot 2022-12-13 at 03 16 31

Maintaining the compatibility for internal storage and SD card is already hard. Adding USB support will be a nightmare for me. I only maintain the repository during my spare time. I will leave this issue open until an undetermined time, or when I get enlightened.

@anggrayudi anggrayudi added the enhancement New feature or request label Dec 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants