0

I'm currently making an android application with the intent to copy all files from a USB flash drive onto my tablet. The tablet is to be locked down, disallowing access to all applications other than the application I am making, the tablet is then to be shipped to users who will be recording video footage onto a USB flash drive using head-mounted cameras, at the end of each day the users are to plug the flash drives into the tablet, during this time, the application will wake up and allow the users to click the "backup" button, the files are then to be copied from the usb drives and saved on the tablet.

The intent is that the user plugs a flash drive named 'Flash_1' into the tablet, then presses a single button on the tablet, the button will then copy all files. Currently the only way I know to access external storage on an Android device is ACTION_OPEN_DOCUMENT_TREE, however this makes the user manually select the USB device, which we do not want.

Is there a way to automatically copy files from a USB device?

The users are assumed to be technology illiterate so we are not asking them to do anything more than plug the flash drive into the device and click the transfer button. The users are also assumed to have no technology outside of the tablet, camera and flash drive.

(I am aware that communication with external USB devices disallows my app from being published on the app store, this is an internal only app to be used for non-profit purposes)

Josh Hunter
  • 45
  • 1
  • 10
  • If you have a custom firmware build for the tablet, you could explore pre-granting rights to your app. This is how built-in file managers work, for example. If you do not have custom firmware for your tablet, then AFAIK you are out of luck. – CommonsWare Nov 16 '22 at 15:36
  • @CommonsWare is it possible to only have to grant rights once? As in, if I grant the rights before giving the tablet to the users, will the tablet remember that I granted rights? – Josh Hunter Nov 16 '22 at 15:47
  • Yes. Once is enough. But only for the same usb stick. – blackapps Nov 16 '22 at 15:52
  • So, do I use ACTION_OPEN_DOCUMENT_TREE in order to grant permission and learn the USB sticks URI and then I just transfer files using the URI and normal File.move()? @blackapps – Josh Hunter Nov 16 '22 at 16:04
  • You cannot grant a permission. You have to wait until you get a permission. If you get one you can make it permanent. – blackapps Nov 16 '22 at 16:31
  • And no normal File.move() as you cannot use the File classes then. Learn how to use Storage Access Framework to copy and delete files. – blackapps Nov 16 '22 at 16:32
  • `am aware that communication with external USB devices disallows my app from being published on the app store,` I'm not aware of that. And hard to believe. – blackapps Nov 17 '22 at 08:24
  • @blackapps it's irrelevant because I'm not going to be publishing the app anyway, it's just an internal app. Not commercial or anything, I just added that paragraph because on similar threads I see the discussion turn towards Google rules and I wanted to keep discussion on topic. – Josh Hunter Nov 18 '22 at 15:42

0 Answers0