How do copy of Big not image file to ASD from non ASD directory

I need to copy to ASD a file selected by user from non ASD directory.
SAF.OpenSingleDocument (with read and write as byte array) was perfectly working but unfortunately for big files (> 5MB) SAF.readAsByteArray is not able to allocate enough memory.
I was trying to use SAF.CopyDocument but SAF. IsCopySupported is giving false and copy is not working (in reality IsCopySupported is giving false also for files that I was able to read and write as a byte array).
Maybe somebody knows how to copy big files to ASD? Thank you

Try using the FileTools1.CopyAsync(String src, String des) from the FileTools Extension by Sunny Gupta.

It raises the event FileTools1.FileCopied(response) after the operation of the method.

As you already know Alexandre, the problem is Google Security. As a last resort you may need your User to upload the file to the Cloud so that your App can download from there. What is the maximum file size you need to move? I'm wondering if the SAF extension has an internal limitation for memory allocation rather than a physical one - in which case, Sunny might be able to introduce an upgrade.

Thank you Chris. Yes, I know about the Android 11+ version security limits, but considering that SAF was in any case able to read those files I guess that the security problem has been overcome already in a certain way. On the other hand - I'm practically sure that this 5MB limit was introduced by SAF because my smartphone had a lot of free memory at that moment (i measured it). And it will be great to create a SAF document copy that will read and write files portion by portion cancelling this limit completly. I'll be glad to become a sponsor for such upgrade.

What file type are you talking about?

Binary files (not images).
Those files are zipped and encrypted daily backup files of sqllite DB and related images and pdf files. Each backup file is about 200MB and they are saved in the directory chosen by the user (on the smartphone or in cloud). In case the user need to restore one of those backup files - he has to select it using SAF. OpenSingleDocument.
I need to copy this backup file to ASD in order to unzip and elaborate it. Thank you

.exe, .bin, ... ?

And where does this file come from? Who created it?

My application is creating those files inside ASD but the user can copy it where he wants (I'm using sharing function). In case of problems (with app or simply because his smartphone will be stolen) he will be able to restore his BACKUP saved somewhere.
Of course I can obliged him to copy his backup to the cloud but I prefer to give him a complete freedom (for example - SD card)

Since, as you say, this file is created by the app itself, there shouldn't be any problems. Simply copy the file into one of the shared folders (or into a hidden subfolder within it, if necessary). Then there is access to it at least as long as the device has not been stolen / lost (however, even after the app has been uninstalled). In the latter case, the file should be uploaded to a server as a precaution so that it can be downloaded again if necessary.

I was trying to put this file in download and in documents and select it with SAF.opensingledocument, but SAF.IsCopySupported is giving always false

Yes, that's true. And the reason is that it tries to allocate bits equal to the file size at once, which for big files is not possible to do as Integer.
https://github.com/vknow360/SAF/blob/beta/com/sunny/saf/SAF.java#L468
This can be fixed.

Unfortunately this is an issue with Android and hence can't be fixed with extension.

1 Like

Thank you in any case!
I'll proceed with a cloud ;-(

Why? Since the file is created by the app itself, you can access it on all Android versions from one of the Shared folder without using SAF.

However, if the device is no longer available or the app has been uninstalled, only a server solution (i.e. downloading) can be considered.

The backup was created by app but after the user is copying it to other folder via sharing function. I was thinking that in this case it will be impossible to use Filecopy extension and I was proceeding with SAF. But I'll try

Because of importance of information it will be preferable not to save it in cloud. My idea was to use an SD card Reader connected to Smartfone via USB cable (there cost is rediculis)

But then you don't even know where the file was copied to by the user.
How do you want to access it afterwards via SAF (without knowing the storage location)?

The use himself is selecting the file via SAF.opensingledocument

Ok, but one can safely assume that the user still remembers where he saved this file.